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

wp-sitemap.xml displays duplicate recurring events #547

Open
r-a-y opened this issue Aug 25, 2024 · 0 comments
Open

wp-sitemap.xml displays duplicate recurring events #547

r-a-y opened this issue Aug 25, 2024 · 0 comments

Comments

@r-a-y
Copy link
Contributor

r-a-y commented Aug 25, 2024

As of WP 5.5, WP generates a wp-sitemap.xml file for all available, public post types: https://make.wordpress.org/core/2020/07/22/new-xml-sitemaps-functionality-in-wordpress-5-5/.

In the generated sitemap for EO's event post type, duplicate recurring events are being displayed.

To fix this, filter the WP sitemap post query args to set EO's 'group_events_by' query parameter to 'series':

/**
 * Do not show all duplicate recurring events in event sitemap.
 */
add_filter( 'wp_sitemaps_posts_query_args', function( $retval, $post_type ) {
	if ( 'event' === $post_type ) {
		$retval['group_events_by'] = 'series';
	}

	return $retval;
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant