I found I needed a way to remove a sidebar widget from only one Post. I figured there was probably a WordPress plugin that could help. It took only a few moments searching to find this:
Widget Logic allows widgets to appear or not depending on standard WP conditional tags, such as is_home() and is_single() and so on.
[Via Freaky Trigger's WordPress Setup | FreakyTrigger.]
Widget Logic.
It was quick and easy to install, but then I was a bit stumped about exactly how to use it. If you’re in the same boat, here’s what to do.
How to hide a sidebar widget for a single Post
- Install and activate Widget Logic.
- Find the ID for the Post (see below).
- Open the widget you wish to hide.
- Add the correct PHP instructions (see below) in the Widget Logic text box below the widget.
- Save the widget.
- Test.
Find the ID for a Post
Find the ID of a Post.
To find the ID for a Post go to the Edit Posts section of the Admin area.
Locate the correct Post and hover over its Title in the list of Posts.
As you hover over the Post title look in the Status Bar of your browser. You should see something a bit like this: http://knowit.co.nz/wp-admin/post.php?action=edit&post=4133.
The first part of what you see doesn’t matter; look for the numerals at the end, after post=. The Post I wanted to work with had the ID of 4133.
Another way to do this is to Command Click (Right Click) on the title of the Post and Copy the URL. Then paste the URL in your text editor to see the ID number.
Add the PHP
Although there were some instructions at the Widget Logic plugin page, I still wasn’t quite sure what I needed to enter into the widget’s new text field. Here’s what I needed to do.
I wanted to have the widget be visible all over my blog, except on the one single-page for the Post whose ID was 4133. I did want the widget to be visible on the Home Page, my About Page, pages where other Posts appeared on their own.
is_single(’4133′)
The PHP code that expresses that requirement is:
!is_single('4133')
In English that says: is not (!) the single Post page (is_single(”) ) whose ID is 4133.
The implication is that if it’s not that specific page then go ahead and display the widget.
In fact that was all I had to enter into the Widget Logic text area below the widget. I didn’t need any opening stuff or ‘if’, or semicolons to finish it off.
If you need to stop specific widgets appearing on particular pages then give Widget Logic a try.
Need help with WordPress?
I provide training and support for users of WordPress-based websites. Contact me for more information.
The Thesis Theme for WordPress (affiliate link) saves me heaps of time. Buy it and find out for yourself. 



{ 8 comments… read them below or add one }
This was very helpful. I’ve been using Widget context, which is cool, but I wanted more customization across the board.
I’m glad this info helped, Chris.
Just an FYI: Widget Logic does not work with WP version 3.0 (at least it doesn’t for me). I’ve found various comments around the Web (including the Widget Logic WP support page) from other users who claim it is not working for them on WP version 3.0, either.
Hi Doug, this blog’s using WordPress 3.0.1 and the plugin is doing its job for me. It removes the BlogHer ad from top of the left sidebar on this page:
http://knowit.co.nz/2010/04/enjoy-quick-efficient-and-timely-tech-training
I was having problems (like others) with getting Widget Context to eliminate occurrences of particular widgets on particular pages. I discovered, though, that if you select the box on the left that says “Single Page” and then list the pages on the right (I used no slashes on either side) on separate lines, it works like a dream.
Hi Miraz
Could you help me please.
On single page I want to extend the page from left to right, because I remove the sidebar with withd logic, could you tell me which file I have to edit and add so I can make it from left to right
Thanks
Andriansah: how you remove the sidebar and extend the main content to the full width of the page depends on which theme you’re using and how it deals with the sidebar.
In the Thesis theme that I use and recommend you simply choose a No Sidebars template for your page.
Is there a way to stop a widget appearing on the homepage, but let it appear on all other posts/pages?
Add your Comment