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')) {
	register_sidebar(array(	
		'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 WordPress Experts at Codeable.

The only WordPress exclusive freelancer platform that connects thousands of customers with the top WordPress freelance experts to work on projects of any size. 

Free estimate • No obligation to hire • 100% risk-free