How to index private posts

#591237
  • Resolved Anonymous
    Rank Math free

    Hello,
    I have a problem that I tried to solve with Bhanu, but he referred me to you due to time constraints.

    I’m using RankMath as an SEO tool (for now the free version, but if we fix the problem below, we’ll probably come to the paid one, since you’re the only ones who interact with us! Thanks a lot!) but I can’t change the <meta name=”robots ” content=”follow, noindex”> for private posts. Both directly during their editing and also in bulk (https://imgur.com/a/gQTIgr7).
    Don’t know how to solve this problem?

    The website functions as a community-supported magazine about nature conservation and social issues. Some articles/posts are therefore behind the donation wall, i.e. only available after the donor has logged in.

    Examples of articles:
    https://sedmagenerace.cz/nadeje-0223/
    https://sedmagenerace.cz/ekologicky-kompost-0223/

    Thanks a lot!
    Martin

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello,

    Thank you for contacting us and sorry for any inconvenience that might have been caused due to that.

    Rank Math automatically noindex your private posts/pages because the main intention of making any page/post private is to hide them from the public and only visible them to the Editors and Administrators.

    However, if you still want to make your private posts index, then you can add the following filter on your website:

    add_filter( 'rank_math/frontend/robots', function( $robots ) {
        global $post;
        $post_ids = array(1,2,3); // Replace 1,2,3 with your post/page ID(s)
    
        if(!empty($post->ID) && is_numeric($post->ID) && in_array((int)$post->ID, $post_ids)){
            $robots['index'] = 'index';
    	$robots['follow'] = 'follow';
        }
        return $robots;
    });
    

    Here’s how you can add filter/hook to your WordPress site: https://rankmath.com/kb/wordpress-hooks-actions-filters/

    If you also want to include your private posts to the sitemap then you’ll have to use the custom sitemap functionality: https://rankmath.com/kb/custom-sitemaps/

    Please don’t hesitate to let us know if you have any other questions.
     
    Thank you.

    Anonymous
    Rank Math free

    Thank you very much for help!!

    Hello,

    We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.

    If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)

The ticket ‘How to index private posts’ is closed to new replies.