add_query_var( 'sitemap' ); $GLOBALS[ 'wp' ]->add_query_var( 'sitemap_n' ); add_rewrite_rule( 'sitemap_index\.xml$', 'index.php?sitemap=1', 'top' ); add_rewrite_rule( '([^/]+?)-sitemap([0-9]+)?\.xml$', 'index.php?sitemap=$matches[1]&sitemap_n=$matches[2]', 'top' ); } /** * Hooked into transition_post_status. Will initiate search engine pings * if the post is being published, is a post type that a sitemap is built for * and is a post that is included in sitemaps. */ function status_transition( $new_status, $old_status, $post ) { if ( $new_status != 'publish' ) return; wp_cache_delete( 'lastpostmodified:gmt:' . $post->post_type, 'timeinfo' ); // #17455 $options = get_wpseo_options(); if ( isset( $options[ 'post_types-' . $post->post_type . '-not_in_sitemap' ] ) && $options[ 'post_types-' . $post->post_type . '-not_in_sitemap' ] ) return; if ( WP_CACHE ) wp_schedule_single_event( time(), 'wpseo_hit_sitemap_index' ); // Allow the pinging to happen slightly after the hit sitemap index so the sitemap is fully regenerated when the ping happens. if ( wpseo_get_value( 'sitemap-include', $post->ID ) != 'never' ) wp_schedule_single_event( ( time() + 60 ), 'wpseo_ping_search_engines' ); } } // Instantiate class $wpseo_sitemaps_admin = new WPSEO_Sitemaps_Admin();