0

So, my sidebar is working just fine on my blog page: beta.cleantelligent.com/blog However, when you click a single post, I'd like that same sidebar to show up.

I am assuming this would be under single.php, right? That code is listed below. Let me know if you need any other code and I'll post it here.

I have the 'blog' sidebar in my page attributes on the Edit Page in Wordpress, but it's just not being recognized by the template, I guess?

Any help would be great. Thanks!

<?php 
get_header(); ?>
<div class="blackbar">
<div class='bbw'>
Blog
</div>
</div>
<div class='cont-wrap'>

<div id="primary">
<?php
$post_obj = $wp_query->get_queried_object();
$post_name = $post_obj->post_name;
if($post_name == 'blog'){
echo 'Blog';
}else{
$parent_title = get_the_title($post->post_parent);
echo $parent_title;
}
?>
<div id="content" role="main">

    <?php while ( have_posts() ) : the_post(); ?>

        <?php get_template_part( 'content', 'archive' ); ?>

    <?php endwhile; // end of the loop. ?>

</div><!-- #content -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
</div>

The blog page is using index.php

<?php
get_header(); ?>
<div class="blackbar">
<div class='bbw'>
<?php
$post_obj = $wp_query->get_queried_object();
$post_name = $post_obj->post_name;
if($post_name == 'blog'){
echo 'Blog';
}else{
$parent_title = get_the_title($post->post_parent);
echo $parent_title;
}
?>
</div>
</div>
<div class='cont-wrap'>
<div id="primary">
    <div id="content" role="main">

        <?php while ( have_posts() ) : the_post(); ?>


            <?php get_template_part( 'content', 'blog' ); ?>



            <?php comments_template( '', false ); ?>

        <?php endwhile; // end of the loop. ?>

    </div><!-- #content -->
</div><!-- #primary -->

<?php get_sidebar(); ?>
</div>

</div><!-- #main -->

Here is my sidebar.php:

<?php

$options = twentyeleven_get_theme_options();
$current_layout = $options['theme_layout'];
$nav = sb_get_page_nav($post);
if ( 'content' != $current_layout ) :
?>
<img class="sidebar-top" src='<?php bloginfo('stylesheet_directory'); ?>/images/sidebar-top.png' />
<div id="secondary" class="widget-area" role="complementary">
<?php
    $post_obj = $wp_query->get_queried_object();
    $post_name = $post_obj->post_name;
    $title = 'cs-' . $post_name; 
    ?>
<?php
    if($post_name == 'news-events'){
        if ( ! dynamic_sidebar( 'sidebar-web' ) ) :
        endif;
    }
?>

<?php if(!$nav['no_nav']) { ?>
    <div class="SimpleSideNav">
        <?php wp_nav_menu(array('container_id' => 'left-navigation','menu' => $nav['title'])); ?>
    </div>
<?php } ?>


<?php if ( ! dynamic_sidebar( 'sidebar-all' ) ) : ?>
<?php endif; // end sidebar widget area ?>
<?php /*
<nav id="left-nav">
    <div class="nav-wrapper">
        <?php if(!$nav['no_nav']) {
            wp_nav_menu(array('container_id' => 'left-navigation','menu' =>     $nav['title']));
        } ?>
    </div>
</nav>
    */ ?>

    <?php if ( ! dynamic_sidebar( $title ) ) : ?>
    <?php endif; // end sidebar widget area ?>
    <img class="sidebar-bot" src='<?php     bloginfo('stylesheet_directory'); ?>/images/sidebar-bot.png' />
</div><!-- #secondary .widget-area -->

<?php endif; 
$parent_title = get_the_title($post->post_parent);
if($parent_title == 'Tour'){
echo"
<script>
jQuery('.w-1').hide();
</script>
";
}
?>
1
  • Which sidebar? There are several sidebars in that code, all with different conditions for display.
    – s_ha_dum
    Commented Dec 24, 2013 at 20:06

1 Answer 1

1

It seems that the sidebar checks whether or not the Post Layout is set to "content". If you remove that check, it should operate the way the main index page does.

Editing / commenting out the following lines in sidebar.php should solve the problem (if not, get you closer):

Find:

if ( 'content' != $current_layout ) :

Replace with:

//if ( 'content' != $current_layout ) :

Towards to end of sidebar.php, find:

<?php endif;

Replace with:

<?php //endif; 

The line above... is just above:

<?php $parent_title = get_the_title($post->post_parent);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.