Skip to main content
1 of 2
Ed Burns
  • 414
  • 2
  • 5

You are not going to be able to prevent anyone from ever loading that page. Even if there is no link to it, you probably have a sitemap generated that creates links to all items. So wanting to block it is the right thing to do but changing the query to try and do it is not.

Probably the best and easiest approach is to use loop templates in your single.php. If you have loop-single.php (for legitimate items) and then loop-disallow.php (for the ones you do not want used), then the following code would help:

$template = 'single';
if(<in taxonomy logic here>) $template = 'disallow';
get_template_part('loop', $template);

Then for your disallow loop, you can just display an Item Not Found or something along those lines. You could also consider adding logic to the header to issue a 404 when one of these pages are hit.

Ed Burns
  • 414
  • 2
  • 5