How to Hide or Show Widgets on Certain WordPress Pages, Posts and Categories

Nur . Posted in How-To, Plugins 682 Views

Sometime we have to hide or show widget on certain Pages, Posts or Categories  to show up different content,  affiliate ads or a poll on particular page or a category.  There are codes for these requirements on WordPress conditional tags, But  I found excellent WordPress plugins named Widget Logic and Widget Context that had the ability to hide or show widgets on your WordPress blog.?

Here are some tip to add some logic to the widgets that are used on your WordPress blog. These functions of this plugin are from the WordPress conditional tags.

1. Widget Logic

Widget Logic lets you control on which pages widgets appear. It uses any of WP’s conditional tags. It also adds a ‘widget_content’ filt

  1. widget-logic screenshot 1The ‘Widget logic’ field at work in standard widgets.
  2. widget-logic screenshot 2The widget_content filter and wp_reset_query options are at the foot of the widget admin page. (Both are off by default.)

One of my friend from Bloggermint  had well explained to make post pretty helpful and have added some common tags that hides or shows widgets and here these are:

is_single() to display the widget only on single pagesis_home() to display the widget only on home page

is_single(12) to display the widget on the post ID 12. The post ID is nothing but a unique number that was allocated to a blog post. So how to find the post? Simple one of my fellow blogger have blogged about it, just head over there.

!is_home() to display the widget on all the places except the homepage.

strpos($_SERVER['HTTP_REFERER'], “google.com”)!=false to display the widget for visitors who comes through Google. You can try the same step to replace Google.com with Facebook.com if you want to have a greet message for Facebook users.

is_single(‘Blogger Tips’) to display the widget on the post titled Blogger Tips. This indirectly helps you in adding a suitable affiliates ads for certain pages.

is_page(‘contact’) to display the widget only on a particular page contact. You can change the value “contact” to any page name of your wish.

is_category(array(5,9,10,11)) to display the widget only for certain category classified by category numbers*. You can even use single category numbers to hide or show widgets.

is_user_logged_in() to display the widget only for logged in users.

Download

2. Widget Context

Show widgets in context – only on certain posts, front page, category or tag pages etc. Widget Context allows you to specify widget visibility settings.

For news and updates regarding this plugin, check www.konstruktors.com

  1. widget-context screenshot 1Widget Context settings added at the end of every widget settings

There is an excellent video about this plugin on WordPress Tip of the Day “Hide or Show Widgets on Certain Pages Using the Widget Context Plugin

Download

Display Widgets Only on Certain Pages
Hide/Display/Show Widgets/Gadgets in Home/post/static/archive Blogger Pages
How to show or hide a widget on certain pages of your blog

Nur

I am a Wordpress, Website Developer and Designer, creator @ WP Arena, Provide Free WordPress consultation and can help to install WordPress in a secure way to small businesses and bloggers.

Free & Professional WordPress Security Service Free & Professional WordPress Security Service

We Love WordPress. WordPress Arena is a place for WordPress Developers and Designers, providing Tips, tricks, tools and resources to build a website or blog on WordPress. We also present The WordPress Showcase for all kind of WordPress Powered Websites.

Recent Comments

Anderson

|

Dont work with post_type? ‘post_type=property&numberposts=1′