mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
Sitemaps: Remove duplicate sticky Posts from Sitemap Post Query.
This changeset sets the `ignore_sticky_posts` parameter to `true` in the default arguments passed to `wp_sitemaps_posts_query_args`. Props RavanH, pbiron, swissspidy, audrasjb, SergeyBiryukov. Fixes #55633. git-svn-id: https://develop.svn.wordpress.org/trunk@53548 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -219,6 +219,7 @@ class WP_Sitemaps_Posts extends WP_Sitemaps_Provider {
|
||||
'no_found_rows' => true,
|
||||
'update_post_term_cache' => false,
|
||||
'update_post_meta_cache' => false,
|
||||
'ignore_sticky_posts' => true, // sticky posts will still appear, but they won't be moved to the front.
|
||||
),
|
||||
$post_type
|
||||
);
|
||||
|
||||
@@ -62,6 +62,30 @@ class Tests_Sitemaps_wpSitemapsPosts extends WP_UnitTestCase {
|
||||
$this->assertArrayHasKey( 'lastmod', $sitemap_entry );
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that sticky posts are not moved to the front of the first page of the post sitemap.
|
||||
*
|
||||
* @ticket 55633
|
||||
*/
|
||||
public function test_posts_sticky_posts() {
|
||||
$factory = self::factory();
|
||||
|
||||
// Create 4 posts, and stick the last one.
|
||||
$post_ids = $factory->post->create_many( 4 );
|
||||
$last_post_id = end( $post_ids );
|
||||
stick_post( $last_post_id );
|
||||
|
||||
$posts_provider = new WP_Sitemaps_Posts();
|
||||
|
||||
$url_list = $posts_provider->get_url_list( 1, 'post' );
|
||||
|
||||
$this->assertCount( count( $post_ids ), $url_list );
|
||||
// Check that the URL list is still in the order of the post IDs (i.e., sticky post wasn't moved to the front).
|
||||
foreach ( $post_ids as $idx => $post_id ) {
|
||||
$this->assertSame( array( 'loc' => home_url( "?p={$post_id}" ) ), $url_list[ $idx ] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for 'wp_sitemaps_posts_show_on_front_entry' filter.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user