Sitemap Exclusion filter results in some 404s
-
Hello,
We don’t want to include posts older than one year in the sitemap, so we’re using the following code to exclude those posts. Since we have approx 4k posts, this results in 4 separatepost-sitemaps$.xml
. The first 2 result in 404 errors, presumably because these pages formerly contained posts older than one year. Any suggestions about how I might resolve this?add_filter('wpseo_exclude_from_sitemap_by_post_ids', function () { $args = array( 'date_query' => array( 'fields' => 'ids', array( 'column' => 'post_date_gmt', 'before' => '1 year ago', ), ), 'posts_per_page' => -1, ); $query = new WP_Query($args); $post_ids = wp_list_pluck($query->posts, 'ID'); return $post_ids; });
I’ve tried the suggestions at https://kb.yoast.com/kb/my-sitemap-is-giving-a-404-error-what-should-i-do/ to no avail.
Thanks in advance
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Sitemap Exclusion filter results in some 404s’ is closed to new replies.