Add Widget Area to Vantage Listings Page

If you are 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.

1
2
3
4
5
6
7
8
9
10
11
12
13
//Register Sidebar
if (function_exists('register_sidebar')) {
	register_sidebar(array(	
		'name'=> 'Vantage Listing',
		'id' => 'vantage listing',
		'description' => 'Single Listing Widget Area',
		'before_widget' => '<div class="widget %1$s">', // '%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).

1
2
3
4
5
6
7
8
<?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.