[Resolved] How to hide no index post?

Home Forums Support [Resolved] How to hide no index post?

Home Forums Support How to hide no index post?

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #2307740
    Akshay

    Hi

    Recently I added a noindex tag on a blog post. But that post is still appearing on the blog page and recent post widget. Is it possible to stop that post from appearing?

    Noindex post: Link

    Blog page: link

    Thanks

    #2307774
    David
    Staff
    Customer Support

    Hi there,

    adding a noindex tag won’t remove a post from your site, its simply a meta tag that search engine bots will see.

    If you want to exclude a post from your blog then add this snippet:

    function exclude_single_posts_archive($query) {
    	 if ( !is_admin() && !is_singular() && $query->is_main_query() ) {
    		  $query->set('post__not_in', array(1223, 776,878) );
    	  }
    }
    add_action('pre_get_posts', 'exclude_single_posts_archive');

    In the array: array(1223, 776,878) is a list of Post IDs replace those with the one ( or many ) that you want to exclude.

    #2308437
    Akshay

    Thanks David,

    One more question. That particular post is still listed in the recent post and category widgets. Is there a way to hide them as well?

    #2308458
    Fernando
    Customer Support

    Hi Akshay,

    As an alternative, you can use a Query Loop Block instead of these two blocks. In the Query Loop Block, you can exclude specific posts.

    Reference: https://docs.generateblocks.com/article/query-loop-overview/

    #2308489
    Akshay

    Thanks a lot Fernando!

    #2308492
    Fernando
    Customer Support

    You’re welcome Akshay!

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.