• Resolved imddev

    (@imddev)


    Hi there,

    I am running a website with TotalContest, Yoast, the W3TC caching plugin and CloudFlare.

    For the purpose of this support thread, I am clearing the entire cache and disabling W3TC as well as purging CloudFlare and pausing caching. I can verify caching is disabled.

    TotalContest creates posts (‘contest_submission’) that can be categorized. I have 3 categories: ‘ese2024’, ‘parichka2023’ and ‘parichka2024’ and I want to exclude all posts inside ‘ese2024’ from the sitemap and indexing. All the posts are publicly published and therefore indexed in the sitemap.

    To exclude ‘ese2024’ from the indexing, I opened phpMyAdmin and found the following in the ‘wp_terms’ table:

    term_id  name     slug     term_group
    66       ese2024  ese2024  

    And to exclude the posts related, I used the following hook:

    /**
     * Excludes terms with ID of 66 from terms sitemaps.
     *
     * @param array $terms Array of term IDs already excluded.
     *
     * @return array The terms to exclude.
     */
    function sitemap_exclude_terms( $terms ) {
        return [ 66 ];
    }
    add_filter( 'wpseo_exclude_from_sitemap_by_term_ids', 'sitemap_exclude_terms', 10, 1 );
    

    With all this said and done, I am still getting the posts from this category indexed in the sitemap.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter imddev

    (@imddev)

    Versions:
    WP – 6.4.3
    Yoast – 22.6

    Plugin Support Maybellyne

    (@maybellyne)

    Hello @imddev,

    Thanks for reaching out regarding excluding terms from your sitemap. I have checked your sitemap index to understand the post type, taxonomies and terms; contest_submission is a custom post type. Looking at the filter you used, you want to exclude the term, ese2024. Am I correct? However, I don’t see it in the contest_submission sitemap, which means the filter worked. If an excluded term is still in the sitemap, please provide the URL.

    I await your response.

    Plugin Support Jose Varghese

    (@josevarghese)

    This thread was marked resolved due to a lack of activity, but you’re always welcome to re-open the topic. Please read this post before opening a new request.

    Thread Starter imddev

    (@imddev)

    Hey, apologies for the delay in responding back to you @maybellyne . This is indeed a CPT, and this particular post at https://parichka.bg/contest/moyataparichka-ese/submission/34123/ is categorized under the term ese2024 and none others.

    Perhaps my understanding of the hook is wrong? I want every post that is contained in the excluded term to be excluded for listing in the sitemap. So – posts X, Y and Z with the same CPT (contest_submission) are in 3 different term_ids in the taxonomy submission_category , I want every term in the taxonomy to be listen on the sitemap, with the exception of the term with an id 66 .

    How can I accomplish that?

    Plugin Support Maybellyne

    (@maybellyne)

    Your setup is unclear. However, in WordPress > Yoast SEO > Settings > Categories & tags, you can set the whole taxonomy archive to noindex and the associated sitemap is disabled but the terms will still be indexed.

    To noindex the specific terms, you need to edit each and noindex in the advanced tab of Yoast SEO meta box

    Also, this filter will exclude a taxonomy while this filter will exclude the term in the taxonomy.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Hook ‘wpseo_exclude_from_sitemap_by_term_ids’ is ineffective’ is closed to new replies.