Continuation of Exclude Custom Post Type with specific status from Sitemap #4093

#429673
  • Resolved G
    Rank Math business

    Hi,

    Some time passed until I heard from our theme developer. He sent me a code snippet which doesn’t work, so I went ahead and wanted to test whether having a double robots tag which basically both says noindex would be a temporary fix. I went ahead and tested it on one specific job which Google is giving me an error for: https://fiks.nl/vacature/skillz-talent-workforce-communicatie-marketing-stage-sittard-12290/

    #-----------------------------------------------------------------#
    # Rank Math: filter the robots meta data.
    # @param array $robots The meta robots directives.
    # Remove action in wp_head
    #-----------------------------------------------------------------#
    
    add_filter( 'rank_math/frontend/robots', function( $robots ) {
    	if(get_post_type() == 'job_listing' && get_post_meta( get_the_ID(), '_filled', true )  && get_the_ID() == '12852') {
    		$robots["index"] = 'noindex';
    		$robots["follow"] = 'follow';
    	}
    	return $robots;
    });

    As you can see in the html it says ‘noindex’ twice now, so that works. The odd thing, it stays in my sitemap. I flushed the sitemap, cleared my website cache and made sure my sitemap isn’t cached as explained by Reinelle.

    My sitemap can be found here: https://fiks.nl/job_listing-sitemap.xml

    What else can I do? Looking forward to your answers. Thanks so much!

Viewing 2 replies - 16 through 17 (of 17 total)
  • G
    Rank Math business

    Thank you so much. You guys have wonderful support. Worked like a charm!

    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 2 replies - 16 through 17 (of 17 total)

You must be logged in to reply to this ticket.