• Danny

    (@dannyfoo)


    I’m helping a friend of mine combine her sidebar into a single file – used to be 1 for homepage (not front page) and 1 for the single, archive etc. This is what I’ve done so far.

    <div class="rightside">
    <?php /* singular affects is_single(), is_page() or is_attachment() */
    if ( is_single() || is_page() || is_search() || is_404() ) { ?>
    
    <div class="categories">
    	<h2><img src="<?php bloginfo('stylesheet_directory');?>/images/categories-h2.jpg" alt="Categories" /></h2>
    	<ul><?php wp_list_categories('title_li=0');?></ul>
    </div>
    
    <div class="video">
    	<h2><img src="<?php bloginfo('stylesheet_directory');?>/images/video.jpg" alt="Video of the Month" /></h2>
    	<p><?php vsf_show_video();?></p>
    	<?php query_posts('showposts=1&amp;cat=1'); ?>
    	<?php while (have_posts()) : the_post(); ?>
    	<h3><a href="<?php the_permalink();?>"><?php the_title(); ?></a></h3>
    	<?php endwhile; ?>
    </div>
    
    <div class="calendar">
    	<div class="cal">
    	<?php sidebarEventsCalendar();?>
    	</div>
    </div>
    
    <div class="ads">
    <!--adsense#sidebar-->
    </div>
    
    <?php } else { ?>
    
    <div class="video">
    	<h2><img src="<?php bloginfo('stylesheet_directory');?>/images/video.jpg" alt="Video of the Month" /></h2>
    	<p><?php vsf_show_video();?></p>
    	<?php query_posts('showposts=1&amp;cat=1'); ?>
    	<?php while (have_posts()) : the_post(); ?>
    	<h3><a href="<?php the_permalink();?>"><?php the_title(); ?></a></h3>
    	<?php endwhile; ?>
    </div>
    
    <div class="calendar">
    	<div class="cal">
    	<?php sidebarEventsCalendar();?>
    	</div>
    </div>
    
    <div class="ads">
    <script type="text/javascript"><!--
    google_ad_client = "pub-0097541961472805";
    /* Pinkspace 300x250, created 12/2/07 */
    google_ad_slot = "9760896219";
    google_ad_width = 300;
    google_ad_height = 250;
    //-->
    </script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>
    </div>
    
    <?php } ?>
    
    <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?>
    <?php endif; ?>
    </div>

    How’s it suppose to work is, the Else properties should execute on is_home(). I’ve switched this around but noticed even single posts/pages displayed the is_home content.

    So what I did was switched the code around to test again, but this time I used what is pasted above. Then I came about another problem, if I added is_archive OR is_category to the IF (which I need to declare), even the homepage displays IF code instead of the else.

    You can see it in: http://www.decorateur.me

    Could someone help me out here? Thanks.

The topic ‘Need help with dynamic sidebar’ is closed to new replies.