Different widget in sidebar for different post and page

Add required widget in sidebar

Create Sidebar


register_sidebar(array(
'name' => __('Contact Attorny', 'legal'),
'id' => 'contact-attorny',
'description' => __('Contact Attorny sidebar that appears on the right.', 'legal'),
'before_widget' => '<aside id="%1$s" class="sidebar-widget widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<div class="sidebar-widget"><h3>',
'after_title' => '</h3></div>',
));

register_sidebar(array(
'name' => __('Twitter', 'legal'),
'id' => 'twitterfids',
'description' => __('Twitter that appears on the right.', 'legal'),
'before_widget' => '<aside id="%1$s" class="sidebar-widget widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<div class="sidebar-widget"><h3>',
'after_title' => '</h3></div>',
));

register_sidebar(array(
'name' => __('Blog Category', 'legal'),
'id' => 'bcats',
'description' => __('Blog Category that appears on the right.', 'legal'),
'before_widget' => '<aside id="%1$s" class="sidebar-widget widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<div class="sidebar-widget"><h3>',
'after_title' => '</h3></div>',
));
register_sidebar(array(
'name' => __('Practice Area', 'legal'),
'id' => 'practicearea',
'description' => __('Practice Area that appears on the right.', 'legal'),
'before_widget' => '<aside id="%1$s" class="sidebar-widget widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<div class="sidebar-widget"><h3>',
'after_title' => '</h3></div>',
));

Sidebar.php


<?php
$legal_options = get_option('legal_theme_options');
?>
<?php if ( is_singular('practice-areas') ) { ?>
<div class="sidebar-box">
<?php if (is_active_sidebar('contact-attorny')) {
dynamic_sidebar('contact-attorny'); }?>
</div>
<div class="sidebar-box">
<?php if (is_active_sidebar('twitterfids')) {
dynamic_sidebar('twitterfids'); }?>
</div>
<div class="sidebar-box">
<?php if (is_active_sidebar('practicearea')) {
dynamic_sidebar('practicearea'); }?>
</div>
<?php } ?>

<?php if ( is_singular('post') ) { ?>
<div class="sidebar-box">
<?php if (is_active_sidebar('contact-attorny')) {
dynamic_sidebar('contact-attorny'); }?>
</div>
<div class="sidebar-box">
<?php if (is_active_sidebar('twitterfids')) {
dynamic_sidebar('twitterfids'); }?>
</div>
<div class="sidebar-box">
<?php if (is_active_sidebar('bcats')) {
dynamic_sidebar('bcats'); }?>
</div>
<?php } ?>

<?php if(is_home()) { ?>
<div class="sidebar-box">
<?php if (is_active_sidebar('contact-attorny')) {
dynamic_sidebar('contact-attorny'); }?>
</div>
<div class="sidebar-box">
<?php if (is_active_sidebar('twitterfids')) {
dynamic_sidebar('twitterfids'); }?>
</div>
<div class="sidebar-box">
<?php if (is_active_sidebar('bcats')) {
dynamic_sidebar('bcats'); }?>
</div>
<?php } ?>

<?php if (is_page_template('page-template/testimonials.php')) { ?>
<div class="sidebar-box">
<?php if (is_active_sidebar('contact-attorny')) {
dynamic_sidebar('contact-attorny'); }?>
</div>
<div class="sidebar-box">
<?php if (is_active_sidebar('twitterfids')) {
dynamic_sidebar('twitterfids'); }?>
</div>
<div class="sidebar-box">
<?php if (is_active_sidebar('practicearea')) {
dynamic_sidebar('practicearea'); }?>
</div>
<?php } ?>

<?php if (is_page_template('page-template/case-results.php')) { ?>
<div class="sidebar-box">
<?php if (is_active_sidebar('practicearea')) {
dynamic_sidebar('practicearea'); }?>
</div>
<div class="sidebar-box">
<?php if (is_active_sidebar('twitterfids')) {
dynamic_sidebar('twitterfids'); }?>
</div>
<?php } ?>

<?php if (is_page(204)) { ?>
<div class="sidebar-box">
<?php if (is_active_sidebar('contact-attorny')) {
dynamic_sidebar('contact-attorny'); }?>
</div>
<div class="sidebar-box">
<?php if (is_active_sidebar('twitterfids')) {
dynamic_sidebar('twitterfids'); }?>
</div>
<?php } ?>

<?php if (is_page(269)) { ?>
<div class="sidebar-box">
<?php if (is_active_sidebar('contact-attorny')) {
dynamic_sidebar('contact-attorny'); }?>
</div>
<div class="sidebar-box">
<?php if (is_active_sidebar('twitterfids')) {
dynamic_sidebar('twitterfids'); }?>
</div>
<div class="sidebar-box">
<?php if (is_active_sidebar('bcats')) {
dynamic_sidebar('bcats'); }?>
</div>
<?php } ?>

<?php if (is_page(206)) { ?>
<div class="sidebar-box">
<?php if (is_active_sidebar('contact-attorny')) {
dynamic_sidebar('contact-attorny'); }?>
</div>
<div class="sidebar-box">
<?php if (is_active_sidebar('twitterfids')) {
dynamic_sidebar('twitterfids'); }?>
</div>
<div class="sidebar-box">
<div class="address_info">
<h4> <?php echo esc_attr($legal_options['contacttitles']); ?> </h4>
<div class="textwidget">
<ul>
<li>
<?php echo esc_attr($legal_options['contactaddresses']); ?><br>
Phone: <?php  echo esc_url($legal_options['pnumbers']); ?><br>
Fax: <?php  echo esc_attr($legal_options['faxnumbs']); ?><br>
E-mail: <a href="mailto:<?php echo sanitize_email($legal_options['cemails']); ?>"><?php echo sanitize_email($legal_options['cemails']); ?></a><br>
Website: <a href="<?php echo esc_url($legal_options['cweb']); ?>"><?php echo esc_url($legal_options['cweb']); ?></a> </li>
</ul>
</div>
</div>
</div>

<?php } ?>

Advertisements

Tagged: , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: