n Name: HQJDW Popular Posts Cache
 * Description: Caches the Zimeiti popular-posts widget and prevents per-request view-count sorting.
 */
defined( 'ABSPATH' ) || exit;

function hqjdw_popular_posts_cache_key( WP_Query $query ) {
    $excluded = $query->get( 'post__not_in' );
    $excluded = is_array( $excluded ) ? array_map( 'absint', $excluded ) : array();
    sort( $excluded, SORT_NUMERIC );
    return 'hqjdw_popular_posts_' . md5( implode( ',', $excluded ) );
}

add_filter( 'posts_pre_query', static function ( $posts, $query ) {
    if (
        is_admin()
        || 'post_views_count' !== $query->get( 'meta_key' )
        || 'meta_value_num' !== $query->get( 'orderby' )
        || 5 !== (int) $query->get( 'posts_per_page' )
    ) {
        return $posts;
    }

    $cache_key = hqjdw_popular_posts_cache_key( $query );
    $ids = get_transient( $cache_key );

    if ( false === $ids ) {
        $query->set( '_hqjdw_popular_cache_key', $cache_key );
        $query->set( 'no_found_rows', true );
        return $posts;
    }

    $ids = array_values( array_filter( array_map( 'absint', (array) $ids ) ) );
    if ( ! $ids ) {
        return array();
    }

    $query->found_posts = count( $ids );
    $query->max_num_pages = 1;

    return get_posts( array(
        'post__in'            => $ids,
        'orderby'             => 'post__in',
        'post_type'           => 'post',
        'post_status'         => 'publish',
        'posts_per_page'      => count( $ids ),
        'no_found_rows'       => true,
        'ignore_sticky_posts' => true,
        'suppress_filters'    => true,
    ) );
}, 10, 2 );

add_filter( 'posts_results', static function ( $posts, $query ) {
    $cache_key = $query->get( '_hqjdw_popular_cache_key' );
    if ( $cache_key && $posts ) {
        set_transient( $cache_key, wp_list_pluck( $posts, 'ID' ), 10 * MINUTE_IN_SECONDS );
    }
    return $posts;
}, 10, 2 );
:wq
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="http://www.fncngg.cn/wp-sitemap-index.xsl" ?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>http://www.fncngg.cn/wp-sitemap-posts-post-1.xml</loc></sitemap><sitemap><loc>http://www.fncngg.cn/wp-sitemap-posts-post-2.xml</loc></sitemap><sitemap><loc>http://www.fncngg.cn/wp-sitemap-posts-post-3.xml</loc></sitemap><sitemap><loc>http://www.fncngg.cn/wp-sitemap-posts-post-4.xml</loc></sitemap><sitemap><loc>http://www.fncngg.cn/wp-sitemap-posts-post-5.xml</loc></sitemap><sitemap><loc>http://www.fncngg.cn/wp-sitemap-posts-post-6.xml</loc></sitemap><sitemap><loc>http://www.fncngg.cn/wp-sitemap-posts-post-7.xml</loc></sitemap><sitemap><loc>http://www.fncngg.cn/wp-sitemap-posts-post-8.xml</loc></sitemap><sitemap><loc>http://www.fncngg.cn/wp-sitemap-posts-post-9.xml</loc></sitemap><sitemap><loc>http://www.fncngg.cn/wp-sitemap-posts-post-10.xml</loc></sitemap><sitemap><loc>http://www.fncngg.cn/wp-sitemap-posts-page-1.xml</loc></sitemap><sitemap><loc>http://www.fncngg.cn/wp-sitemap-taxonomies-category-1.xml</loc></sitemap><sitemap><loc>http://www.fncngg.cn/wp-sitemap-users-1.xml</loc></sitemap></sitemapindex>
