php - WordPress sidebar: appear only on certain pages -


how can edit php wordpress sidebar appear on select pages (i.e. not on home , pages)?

i'd prefer php on css if possible.

you can use function is_page() in template , rendering sidebar if need to.

small example, in sidebar.php of twentyten theme of wordpress

<div id="secondary" class="widget-area" role="complementary">         <ul class="xoxo">             <?php               if (is_page('my-page')) {                    dynamic_sidebar( 'secondary-widget-area' ); }             ?>         </ul> </div><!-- #secondary .widget-area --> 

this little snippet outputs sidebar if in page has slug 'my-page'.
hope helps!


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -