Displaying a widget on a single WordPress post

This content is 11 years old. I don't routinely update old blog posts as they are only intended to represent a view at a particular point in time. Please be warned that the information here may be out of date.

I’ve used WordPress’ conditional tags in the past, for example to make sure that something only shows on a certain type of page or post but, a few months ago, I wanted to limit some code to only run on a specific post – and that was proving to be a challenge.  Then I found a useful plugin called Widget Logic.  As the name suggests, it adds some logic to widgets such that they only appear according to the rules specified using conditional tags.

All I needed to add was is_single('postnumber') to limit the widget to appearing only on the post I specified.  It’s also been handy to limit my warning that older content may be out of date so that it’s not shown on pages, only on posts (using !is_page()).

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.