Tag exclusion on HTML Sitempa make page broken

#604249
  • Resolved Anonymous
    Rank Math free

    Hi,

    I’ve put this code on rank-math.php file inside my theme folder.

    add_filter(‘rank_math/sitemap/html_sitemap_taxonomies’, function ($taxonomies) {

    $taxonomies=array(‘category’);

    return $taxonomies;
    }, 10, 1);

    but the HTML page is broken after this apply.

    I need to remove tags from the HTML Sitemap.

    I’m using shortcode mode to display HTML Sitemap.

    any fix you suggest?

    thank you!

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

    Thank you for contacting Rank Math support. We’re sorry to hear that you’re having trouble with the HTML sitemap.

    It seems that the code you’re using is not correct. You should use single quotes instead of curly quotes for the filter and the array values. Also, you should use unset() to remove tags from the taxonomies array, instead of overriding it with a new array.

    Here’s the correct code that you can try:

    
    add_filter( 'rank_math/sitemap/html_sitemap_taxonomies', function( $taxonomies ) {
        // Remove tags from the taxonomies array
        unset( $taxonomies['post_tag'] );
        // Return the modified array
        return $taxonomies;
    }, 10, 1 );
    

    Please add this code to your rank-math.php file and clear your cache. Then check if the HTML sitemap is working properly.

    That said, you do not need to use code to remove tags from your HTML sitemap. You can remove it by navigating to Rank Math > Sitemap Settings > Taxonomies > Tags and disabling the option that says Include in HTML Sitemap

    We hope this helps. If you have any other questions or issues, please let me know.

    Have a great day! 😊

    Anonymous
    Rank Math free

    Hello,

    Thank you for your response.

    the code I’ve copied from the developer filter hooks page and there are single quotes, maybe when I paste it here the quotes changed to curly. <= https://prnt.sc/py5Blkasd98q

    thanks for the given code.

    and for pointing out the settings on the options page. I used the GUI option, and that works.

    Thank you!

    Hi there,

    We’re delighted to hear that this issue has been resolved. We appreciate your kind words and your support.

    I’m closing this ticket now but if you ever have another question or need any help in the future, please don’t hesitate to create a new forum topic. We’ll be more than happy to assist you again.

    Thank you for choosing Rank Math and have a wonderful day!

    Cheers

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

The ticket ‘Tag exclusion on HTML Sitempa make page broken’ is closed to new replies.