Skip to content

How to Hide or Show Widgets on Certain WordPress Pages

0
515
How to Hide or Show Widgets on Certain WordPress Pages
Sometimes we have to hide or show widgets on certain Pages, Posts or Categories to show up different content, affiliate ads or a poll on a particular page or a category. This can be achieved via using WordPress Conditional Tags, but there are also plugins that do the same job without code. Widget Options and Block Visibility can both hide or show content on chosen pages, posts and categories. A note before you start: Widget Logic, which this article originally recommended, was permanently removed from the WordPress plugin directory in April 2026. If it is still active on your site, replace it with one of the options below and delete it.

1. Widget Options

Widget Options is the maintained equivalent of Widget Logic. It adds visibility controls to every widget, so you can show or hide it by page, post, category, post type, device or user role, and it also accepts raw conditional-tag logic if you prefer to write it yourself. If your site uses the block editor for its sidebars rather than classic widgets, Block Visibility does the same thing for blocks.
  1. The 'Widget logic' field at work in standard widgets.
  2. The widget_content filter and wp_reset_query options are at the foot of the widget admin page. (Both are off by default.)
Here are some common tags explained that hides or shows widgets on WordPress Posts and Pages:
  1. is_single() to display the widget only on single pages is_home() to display the widget only on home page
  2. 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.
  3. !is_home() to display the widget on all the places except the homepage.
  4. 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 greetings message for Facebook users.
  5. 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.
  6. 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.
  7. 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.
  8. is_user_logged_in() to display the widget only for logged in users.

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.

3. Widget Options

Widget Options lets you show or hide pages via checkboxes, which means you don’t need any coding work! This feature is available in both the free and premium versions. Not only does it allow you to control page visibility, it also lets you do the same with your posts. You can provide users with sidebar contents that are relevant to each of your posts. Hope, this post caters your need of Widget visibility on certain WordPress Pages. Please let me know in comments if there is any other option available.
Noor Mustafa RazaN
WRITTEN BY

Noor Mustafa Raza

I am a WordPress Developer and Designer, author @WPArena. I am providing Free WordPress consultation and can help you to install WordPress in a secure way to small businesses and bloggers.

Responses (0 )

  • ‌
    ‌
    ‌
    ‌
    ‌
    ‌
  • ‌
    ‌
    ‌
    ‌
    ‌
    ‌
  • ‌
    ‌
    ‌
    ‌
    ‌
    ‌