Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some sitemaps are missing from index after applying filter to remove items #20559

Open
2 tasks done
amboutwe opened this issue Aug 10, 2023 · 1 comment
Open
2 tasks done

Comments

@amboutwe
Copy link
Member

  • I've read and understood the contribution guidelines.
  • I've searched for any related issues and avoided creating a duplicate issue.

Please give us a description of what happened

When filtering a sitemap to remove a large quantity of items and leaving a small number of items, the sitemap index may be missing additional sitemaps.

  • wpseo_sitemap_exclude_author (tested)
  • wpseo_exclude_from_sitemap_by_post_ids (untested but similar)
  • wpseo_exclude_from_sitemap_by_term_ids (untested but similar)

To Reproduce

Step-by-step reproduction instructions

Starting with a vanilla installation:

  1. Create 1050+ users (I used FakerPress) so you have two author sitemaps
  2. Install and activate Yoast SEO (free)
  3. Go to Admin > Yoast SEO > Settings > Advanced > Author archives
  4. Set 'Enable author archives' to Enabled
  5. Set 'Show author archives in search results' to Enabled
  6. Set 'Show author archives without posts in search results' to Enabled
  7. Save settings
  8. Go to sitemap_index.xml and see multiple author sitemaps (1000 on the first, remainder on the second)
  9. Add code snippet (below) to remove all but 1 user from each sitemap
  10. Go to sitemap_index.xml and see one author sitemap
  11. Manually check the second author sitemap and see that it contains the other user

Expected results

Sitemap index would contain 1 author sitemap with all authors
OR
Sitemap index would contain link to each valid author sitemap

Actual results

Sitemap index contains 1 author sitemap with only authors from that sitemap. Additional author sitemaps load with the correct authors but are not shown in the index.

Screenshots, screen recording, code snippet

screenshot_063

Technical info

Code snippet

function sitemap_exclude_authors( $users ) {
   return array_filter( $users, function( $user ) {
	   $authorsToKeep = array( 102, 1 );
        if ( in_array($user->ID, $authorsToKeep ) ) {
            return true;
        }
        return false;
    } );
}

add_filter( 'wpseo_sitemap_exclude_author', 'sitemap_exclude_authors' );

Used versions

  • Device you are using: Desktop
  • Operating system: Win11
  • PHP version: 7.4.33 (Supports 64bit values)
  • WordPress version: 6.3
  • WordPress Theme: Twenty Twenty-Three
  • Yoast SEO version: 20.13
  • Relevant plugins in case of a bug: N/A
@amboutwe
Copy link
Member Author

Please inform the customer of conversation # 1045276 when this conversation has been closed.

@jeroenrotty jeroenrotty added the IM label Aug 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants