Fixing the sidebar

When the option to list the posts containing an image is turned on the default WordPress sidebar template thinks an image page in the Photopress album is a search page (it is – that’s how we know if an image is used in a post). While correct, this makes the sidebar ugly. But it’s such a neat feature, it’d be a shame to disable it. Here’s how to fix the default template’s sidebar.php:

1. Look for is_search() and add && empty($_GET['pp_image']) to that elseif statement. (this suppresses the search stuff when it’s displaying an image)

2. look for is_home() and add || !empty($_GET['pp_image']) to that if statement. (this shows the normal homepage sidebar when it’s an image)

Here’s a zipped replacement sidebar.php if you don’t want to do this yourself.

Avatar photo

By isaac

I like cats. he/him