Exclude one language in sitemap

#90826
  • Resolved Cnk
    Rank Math free

    Hello, I’m using Polylang to my website and have 2 languages at this time, but other language is not finished yet, so I excluded it by adding meta noindex in header (in template), but don’t have idea how to exclude this language from RankMath sitemap.

    How I can do it?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Alberto
    Rank Math business

    Hello,

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

    Right now there is not a specific function for that but I will share this thread with the dev team to see if there is some workaround for this.

    Looking forward to helping you. Thank you.

    ​​​​​​​

    Cnk
    Rank Math free

    Don’t know WPML, but in Polylang it’s possible to use something like this:
    <?= pll_current_language(‘slug’) ?>
    in PHP code. This returns language code like ‘en’, ‘de’, ‘pl’ etc.

    https://polylang.pro/doc/function-reference/
    http://hookr.io/functions/pll_current_language/
    https://polylang.wordpress.com/documentation/documentation-for-developers/functions-reference/

    Alberto
    Rank Math business

    Hello,

    Thank you for contacting Rank Math today.

    Then you could exclude the content from sitemap by setting it to noindex. You can make use of the following filter to noindex them (you need to add the condition to check the language in Polylang):

    /**
     * Allows filtering of the robots meta data.
     *
     * @param array $robots The meta robots directives.
     */
    add_filter( 'rank_math/frontend/robots', function( $robots ) {
         global $wp;
         // Add here your conditional to check the slug
         // filter for only a specific post type
         // Then, if you want to exclude it:
            $robots['index'] = "noindex";
            
    
    	return $robots;
    });

    Looking forward to helping you. Thank you.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

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

The ticket ‘Exclude one language in sitemap’ is closed to new replies.