Code Snippets

Add Widget Area to Vantage Listings Page

Add a Widget Area to Listings Pages in the App Themes Vantage Theme for WordPress.

If you happen to be developing a Directory Site with AppThemes Vantage as your base directory theme, it’s quite likely that you’ll want to add a Widget Area to your Listings pages.

The way I do this involves two basic code snippets, and requires that you are using a child theme.

First, you need to register a new sidebar. To do this, add the following code to your functions.php file.

//Register Sidebar
if (function_exists('register_sidebar')) {
		'name'=> 'Vantage Listing',
		'id' => 'vantage listing',
		'description' => 'Single Listing Widget Area',
		'before_widget' => '<div>', // '%1$s' adds a unique class for each widget area added
		'after_widget' => '</div>',
		'before_title' => '<h4>',
		'after_title' => '</h4>'

Next you need to add the newly registered sidebar/widget area to the single-listing.php (in your child theme).

<?php the_listing_files(); ?>//look for this line in the file
    <div id="listing-widget">//begin code snippet to add
    <?php if ( ! dynamic_sidebar('vantage listing')) : ?>
    <h2>This will appear if there is no widget added to the area</h2>
    <?php endif; ?></div>//end code snippet to add
<div id="listing-tabs">//this is also already in the single-listing.php file

Notice that I wrapped the widget area in the div class listing-widget. You will want to do the same so that you can target this widget area with CSS.

Hire a WordPress Expert

Get hourly and project based theme customization, theme tweaks, and development help from an experienced Kelowna WordPress developer.  We’ve been building WordPress websites full-time for over a decade. We can help you.