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

Fixed the sitemap query to disregard trashed posts. #8238

Merged
merged 1 commit into from
Nov 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion class.jetpack-cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -1059,13 +1059,14 @@ public function partner_provision( $args, $named_args ) {
* ## OPTIONS
*
* rebuild : Rebuild all sitemaps
* --purge : if set, will remove all existing sitemap data before rebuilding
*
* ## EXAMPLES
*
* wp jetpack sitemap rebuild
*
* @subcommand sitemap
* @synopsis <rebuild>
* @synopsis <rebuild> [--purge]
*/
public function sitemap( $args, $assoc_args ) {
if ( ! Jetpack::is_active() ) {
Expand All @@ -1078,6 +1079,11 @@ public function sitemap( $args, $assoc_args ) {
WP_CLI::error( __( 'Jetpack Sitemaps module is active, but unavailable. This can happen if your site is set to discourage search engine indexing. Please enable search engine indexing to allow sitemap generation.', 'jetpack' ) );
}

if ( isset( $assoc_args['purge'] ) && $assoc_args['purge'] ) {
$librarian = new Jetpack_Sitemap_Librarian();
$librarian->delete_all_stored_sitemap_data();
}

$sitemap_builder = new Jetpack_Sitemap_Builder();
$sitemap_builder->update_sitemap();
}
Expand Down
2 changes: 2 additions & 0 deletions modules/sitemaps/sitemap-librarian.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,12 @@ public function query_sitemaps_after_id( $type, $from_id, $num_posts ) {
"SELECT *
FROM $wpdb->posts
WHERE post_type=%s
AND post_status=%s
AND ID>%d
ORDER BY ID ASC
LIMIT %d;",
$type,
'draft',
$from_id,
$num_posts
),
Expand Down