[wp-hackers] How to prevent sidebar widgets on Pages?

Mike Schleif wordpress at helices.org
Fri Dec 9 04:21:29 UTC 2011

I've inherited a custom WordPress theme (http://prismmpls.org) that uses 
the (left) sidebar for custom hierarchical menus.

I'm told that they planned a blog; but, they never implemented it. I 
have setup the blog and it works great! I want to use widgets in 
conjunction with ONLY the blog and blog posts.

I've hacked some PHP so that - in most cases - when their sidebar menus 
show, NO widgets show.

However, when a Page has NO sidebar menu, widgets show - I don't want this.

Also, on the blog Page, there is NO sidebar menu and the widgets show, 
but far down the Page. What's up with this?

In their sidebar.php, I added "!$children && " to their code:
<?php if ( !$children && !dynamic_sidebar( 'sidebar-widget-area' ) ) : ?>

Such as it is, that is what's working now.

What PHP code will prevent widgets in the sidebar for Pages?

How could I get sidebar widgets to show properly ONLY for the blog Page?

Where ought that code to go?

Please, advise.

Thank you.

Best Regards,


More information about the wp-hackers mailing list