Did you ever want to display a particular widget on one page, but not on another? Or only when viewing a certain category? You can do it using the Widget Logic plugin, and by following some simple instructions that will tell your widgets when to show up, and when to take a hike.
First, let’s install and activate the plugin. Then we will look at the basic instructions you’ll use to tell your widgets when to display.
Now, let’s learn how to create some snippets of code that will tell your newly installed Widget Logic what to do with your widgets.
just the main blog page
everywhere EXCEPT this specific WP ‘page’
category page of one of the given category IDs
(hint – installing the plugin WP Show ID will be helpful for finding the category ID’s for this one)
is_single() && in_category(‘baked-goods’)
single post that’s in the category with this slug
displays widget only for administrators
widget to show when clicked through from a google search
is_category() && in_array($cat, get_term_children( 5, ‘category’))
category page that’s a descendent of category 5
global $post; return (in_array(77,get_post_ancestors($post)));
WP page that is a child of page 77
global $post; return (is_page(‘home’) || ($post->post_parent==”13″));
home page OR the page that’s a child of page 13