Issue Excluding Testimonial Archive Page from Sitemap

#896838
  • Resolved Jana H.
    Rank Math free

    Hello RankMath Support Team,

    I am having trouble excluding the testimonial archive page ([redacted]/testimonial/) from my client’s testimonial sitemap [redacted]/testimonial-sitemap.xml. Here’s what I have done so far:

    1. I disabled the archive option for testimonials in the RankMath settings under Titles & Meta > Post Types.
    2. I deleted the cache
    3. I added the following filter code to the functions.php file to exclude the URL:

    add_filter( ‘rank_math/sitemap/entry’, function( $url, $type ) {
    if ( $type === ‘pt-archive’ && $url[‘loc’] === ‘[redacted]/testimonial/’ ) {
    return false; // Exclude this URL from the sitemap
    }
    return $url;
    }, 10, 3 );

    Despite this, the archive page remains in the sitemap. Could you please advise on how to permanently remove this page from the sitemap?

    Thank you for your assistance.

    Best regards,
    Jana

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

    We apologize for the issue you are facing with excluding the testimonial archive page from your sitemap. Thank you for providing detailed information about the steps you’ve already taken.

    It seems like you are on the right track by using the filter to exclude the URL. However, there are a couple of things you might want to check:

    1. Ensure the Filter is Correctly Implemented: Make sure that the filter code is placed correctly in your functions.php file and that there are no syntax errors. The code you provided looks good, but ensure that it is not being overridden by any other code.

    2. Check for Caching: Since you’ve already cleared the cache, ensure that there are no other caching plugins or server-side caching that might be affecting the sitemap. Sometimes, caching can cause changes not to reflect immediately.

    3. Disable Sitemap Caching: You can also try adding this line to your functions.php file to disable sitemap caching:

      add_filter( 'rank_math/sitemap/enable_caching', '__return_false' );

      This will ensure that Rank Math generates the sitemap dynamically without caching issues.

    4. Recheck Rank Math Settings: Double-check your Rank Math settings under Sitemap Settings to ensure that there are no conflicting settings that might be causing the archive page to appear in the sitemap.

    If after trying these suggestions the issue persists, please reply to this ticket, and a human agent from the Rank Math Support team will take over and assist you further.

    Thank you for your patience, and we hope to resolve this issue for you soon!

    Jana H.
    Rank Math free

    Hello,

    I have followed the steps you suggested, including adding the code to disable sitemap caching in the functions.php file. Unfortunately, the testimonial archive page (/testimonial/) is still appearing in the sitemap, even though both pieces of code are now correctly added in the functions.php file.

    PS: I only want to remove the specific archive page (/testimonial/) from the sitemap. I do not want to remove any of the individual testimonial pages (e.g., /testimonial/buddy/).

    Could you please advise on further steps?

    Thank you again,
    Jana

    Hello,

    We have updated the filter on your site to remove the archive link of that post type.

    Here’s the revised code for your reference:

    add_filter( 'rank_math/sitemap/post_type_archive_link', function( $archive_url, $post_type ){
    if ($post_type == 'testimonial'){ // match to the actual post type name
    	$archive_url = false;
    }
    	return $archive_url;
    }, 10, 2 );

    Also, please note that the code might get removed once your theme updates since it’s in your theme’s functions.php file. To avoid that, you can apply the filter via the rank-math.php file or Code Snippets plugin.

    Here’s a guide you can follow:
    https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Hope that helps.

    Jana H.
    Rank Math free

    I Reinelle,

    thank you so much!

    The sitemap looks good now.

    PS: Would it be possible to remove the URL name or at least the first part? I forgot that this thread is public.

    best,
    Jana

    Hello,

    We have removed your domain name from the URL in your first post.

    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 5 replies - 1 through 5 (of 5 total)

The ticket ‘Issue Excluding Testimonial Archive Page from Sitemap’ is closed to new replies.