Support » Plugin: All in One SEO Pack » Exclude category on homepage

  • Resolved bobsled

    (@bobsled)


    When I exclude a category from showing on the homepage with a plugin or with the function below, the pages with these categories are also removed from the xml sitemap.

    Is there a way around this behaviour, so that the pages are still listed on the sitemap?

    //* Exclude a Category from WordPress Homepage
    function exclude_category_home( $query ) {
    if ( $query->is_home ) {
    $query->set( ‘cat’, ‘-627 -306’ );
    }
    return $query;
    }

    add_filter( ‘pre_get_posts’, ‘exclude_category_home’ );

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Michael Torbert

    (@hallsofmontezuma)

    WordPress Virtuoso

    Hi @bobsled

    This code is working for me.
    You may have a caching issue. Try using dynamic sitemaps and clear all caching.

    Hi Michael,

    If I deactivate the Dynamically Generate Sitemap option, all is okay and I see all pages listed.

    But when I activate it, the 100 or so pages I have in categories 627 and 306 disappear again from the sitemap.

    So I suppose my next question is if it’s okay to use the sitemap without the Dynamically Generate Sitemap option set?

    Plugin Author Michael Torbert

    (@hallsofmontezuma)

    WordPress Virtuoso

    Technically it’s ok for now to use static sitemaps instead of dynamic, but it’s older technology that we’ll be removing eventually, so it’s best to have dynamic working.

    We’d like to investigate and see why this isn’t working for you. You can contact us here and use this forum thread’s URL where it asks for a license key https://semperplugins.com/contact/

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.