I frequently publish posts that I need to be hidden. They need to be published, so that someone who has their url can go to them, but I don't want them showing up on my homepage, in my recent posts widget, on my blog page, in my categories etc. I know I can normally use the WP Hide Post plugin for this, but somehow that isn't working for my site. When I create a new post and choose all the hide options WP Hide Post offers, the post still shows up on my blog page (which isn't my homepage).

I've looked around here and found some similar topics to hide posts using code, but only to hide posts from one location, for example from the recent posts widget or from the homepage or from...

I'm searching for a way to hide them from practically everywhere without having to add several lines of code each time I publish a post that needs to be hidden.

Would really appreciate it if someone could help me. Bummed that the WP Hide Post plugin doesn't work for me:/


PS I'm know publishing those posts as pages using WP Hide Post to hide the pages, this works, but it clutters up my pages list.

  • that would require something similar to WP Hide Post. So why not tell the author you have some problem with his plugin?
    – JMau
    Commented Dec 21, 2013 at 10:21
  • I've tried to contact him several times, both through his website as through the Wordpress Support forum for the plugin. No answer... Commented Dec 22, 2013 at 22:17
  • Then drop it. You're right.
    – JMau
    Commented Dec 23, 2013 at 12:07

1 Answer 1


here is a code example to hide post. However you need to use a custom meta for this to work. So, add a new meta with the post you want to hide. Use meta key name as 'hidethis' and use value '1'. Don't use the quote marks, just the texts.

Next this is to add a code to your themes functions.php. You can edit it directly from your wp-admin -> themes -> editor page. Just find the file name (on right side) functions.php and add the following code, then hit update button.

add_action( 'pre_get_posts', 'pre_get_posts_127256', 9999 );
function pre_get_posts_127256($q){
    if( is_admin() )

    if( is_singular() )

    $mq = $q->get('meta_query');
    $nm = array('key' => 'hidethis', 'compare' => 'NOT EXISTS');
    $mq[] = $nm;

    $q->set('meta_query', $mq);

This should be hiding the post u added meta key 'hidethis' with a value.

  • Thanks Shazzad, but I think I'll first have to do a little research on 'meta key name' :D However, I think I've found a solution: I forgot my theme offers the possibility to exclude categories from pages with posts. So I can use that to exclude the cat. I put the posts that I want to hide in from my posts page and then use WP Hide Post to hide the posts from everywhere else. I've also disabled the 'next/previous' post navigation so that the posts don't show up there. I'd just like to know how to also keep that cat. out of the post meta info, but I've opened a new thread for that. Commented Dec 22, 2013 at 22:18
  • PS Very strange, I couldn't add a longer comment:/ Commented Dec 22, 2013 at 22:22
  • 2
    A taxonomy term would be more performant here than a meta key/value, but it would work the same way in the end
    – Tom J Nowell
    Commented Dec 2, 2014 at 18:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.