Need to exclude sidebar from homepage: Dynamic Sidebar
-
I am having a problem getting my sidebar to not show on my ‘home’ page. I have gotten it to show on my other pages but I want to exclude it from just my homepage. I have tried conditional tags, but I am no expert and might not be adding them in the right place. Also I haven’t seen this dynamic sidebar coding very many places. Please help!
The code for the current sidebar in my page.php file is:
<!– subcontent …………………………… –>
<div id=”subcontent”>
<?php if ( function_exists(‘dynamic_sidebar’) && dynamic_sidebar() ) : else : ?>
<?php endif; ?></div> <!– /subcontent –>
-
I’d replace it with this:
<div id="subcontent"> <?php if (!is_home() && function_exists('dynamic_sidebar')) { dynamic_sidebar(); } ?> </div>
That didn’t seem to do anything…any other ideas?
… What do you mean it didn’t do anything? You did something wrong if that code didn’t work.
Are you using any sort of cache, like WP-Super-Cache? Clear the cache to see changes if you are.
I obviously am doing something wrong b/c when I plug that into my page.php file the sidebar still exists in the home page. I have even tried changing the actual sidebar.php file to include that code. And vice versa. My page URL is http://blog.whateverymerchantshouldknow.com/
My page.php file now reads:<?php get_header(); ?>
<!– subcontent …………………………… –>
<div id=”subcontent”>
<?php if (!is_home() && function_exists(‘dynamic_sidebar’)) {
dynamic_sidebar();
} ?>
</div> <!– /subcontent –><!– content …………………………… –>
<div id=”content”><?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>
<?php wp_link_pages(); ?>
<?php $sub_pages = wp_list_pages( ‘sort_column=menu_order&depth=1&title_li=&echo=0&child_of=’ . $id );?>
<?php if ($sub_pages <> “” ){?>
<p>Sub Pages Found</p>-
<?php echo $sub_pages; ?>
<?php }?>
<?php endwhile; ?>
<?php endif; ?>
<?php comments_template(); ?>
</div> <!– /content –><?php get_footer(); ?>
And the sidebar.php file reads: <hr class=”low” />
<!– subcontent …………………………… –>
<div id=”subcontent”>
<?php if (!is_home() && function_exists(‘dynamic_sidebar’)) {
dynamic_sidebar();
} ?><?php /**
* Pages navigation. Disabled by default because all new pages are added
* to the main navigation.
* If enabled: Blix default pages are excluded by default.
*
?>
<h2>Pages</h2>
<ul class=”pages”>
<?php
wp_list_pages(‘title_li=&sort_column=menu_order’);
?><?php */ ?>
<?php if ()?>
<h2>Categories</h2><ul class=”categories”>
<?php
if (function_exists(‘wp_list_categories’))
{
wp_list_categories(‘title_li=’);
}
else
{
wp_list_cats(‘optioncount=0&hierarchical=0’);
}
?><h2>Links</h2>
<ul class=”links”>
<?php get_links(‘-1’, ‘- ‘, ‘
- “>Entries (RSS)
- “>Comments (RSS)
- ‘,’
‘, ”, 0, ‘name’, 0, 0, -1, 0); ?>
<h2>Feeds</h2>
<ul class=”feeds”>
<?php } ?>
<?php if (is_single()) { ?>
<h2>Calendar</h2>
<?php get_calendar() ?>
<h2>Most Recent Posts</h2>
<ul class=”posts”>
<?php BX_get_recent_posts($p,10); ?><?php } ?>
<?php if (is_page(“archives”) || is_archive() || is_search()) { ?>
<h2>Calendar</h2>
<?php get_calendar() ?>
<?php if (!is_page(“archives”)) { ?>
<h2>Posts by Month</h2>
<ul class=”months”>
<?php get_archives(‘monthly’,”,”,’‘,”); ?>
<?php } ?>
<h2>Posts by Category</h2>
<ul class=”categories”>
<?php wp_list_cats(‘sort_column=name&hide_empty=0’); ?><?php } ?>
<?php endif; ?></div> <!– /subcontent –>
Thanks so much:)
Worked for me. Thanks Otto42!!
- The topic ‘Need to exclude sidebar from homepage: Dynamic Sidebar’ is closed to new replies.