Title: Difference between query and wp admin page
Last modified: October 8, 2025

---

# Difference between query and wp admin page

 *  Resolved [jspenney](https://wordpress.org/support/users/jspenney/)
 * (@jspenney)
 * [8 months, 1 week ago](https://wordpress.org/support/topic/difference-between-query-and-wp-admin-page/)
 * There is a difference in order between the WPPP admin page and the pages that
   are pulled by my code. Can someone give me any ideas for the difference? Code
   follows.
 * The WPS Agenda Needs Strong Wills to Counter Rough Headwinds
   210 viewsRussia 
   Praises Trump but Heaps Scorn on Its EU Neighbors209 views[UN: Oct. 3] Hamas 
   to Release Hostages, Older People’s Rights & More29 viewsMadam SG: Can the UN
   Finally Smash Its Glass Ceiling?20 viewsThe Case of Ruben Vardanyan, a Travesty
   of Justice12 views
 * Rank 1: The UN’s Gender Parity Goals: The Backlash Begins (ID: 27161, Type: post)
   
   Rank 2: Could the Taliban Join the UN? They’ll Need to End Their ‘Gender Apartheid’
   System (ID: 75046, Type: post)Rank 3: The WPS Agenda Needs Strong Wills to Counter
   Rough Headwinds (ID: 93650, Type: post)Rank 4: Russia Praises Trump but Heaps
   Scorn on Its EU Neighbors (ID: 93688, Type: post)Rank 5: No Nobel Peace Prize
   for President Trump (ID: 86972, Type: post)
 * /**
    * Retrieves the top 5 popular post IDs (post and article) from the last 
   7 days,  * excludes specific IDs, and caches the result for 12 hours. * * [@return](https://wordpress.org/support/users/return/)
   array Array of popular post IDs, or an empty array on failure. */function cwpai_get_popular_posts_ids_weekly(){//
   Define the transient key and cache time (12 hours) $transient_key = ‘cwpai_popular_posts_ids_weekly’;
   $cache_time = 12 * HOUR_IN_SECONDS;  // Attempt to get cached data $post_ids 
   = get_transient( $transient_key ); // If no cache, generate the data if ( false
   === $post_ids ) {  $post_ids = array();  // 1. Verify WPP Query Class exists 
   if ( class_exists( ‘\WordPressPopularPosts\Query’ ) ) {  $exclude_ids = ‘16817,6620,77812,22232,39656’;
   $query_args = array( ‘range’ => ‘last7days’, ‘limit’ => 5, ‘post_type’ => ‘post,
   article’, // FIX: The parameter for excluded IDs is ‘exclude’, not ‘pid’ ‘exclude’
   => $exclude_ids,  ‘order_by’ => ‘views’, ); // Use the WPP Query class $query
   = new \WordPressPopularPosts\Query( $query_args ); $popular_posts = $query->get_posts();
   if ( is_array( $popular_posts ) && ! empty( $popular_posts ) ) { foreach ( $popular_posts
   as $popular_post ) { $post_ids[] = (int) $popular_post->id; } } } else { error_log(‘
   WordPress Popular Posts Query class not found.’ ); return array(); } // Cache
   the result (even if empty) set_transient( $transient_key, $post_ids, $cache_time);}//
   Ensure the array only contains the top 5, even if the query returns more/less
   unexpectedly return array_slice( $post_ids, 0, 5 );}

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Thread Starter [jspenney](https://wordpress.org/support/users/jspenney/)
 * (@jspenney)
 * [8 months, 1 week ago](https://wordpress.org/support/topic/difference-between-query-and-wp-admin-page/#post-18673829)
 * The first list is WPPP admin page listing and the second i the results of my 
   query
 *  Thread Starter [jspenney](https://wordpress.org/support/users/jspenney/)
 * (@jspenney)
 * [8 months, 1 week ago](https://wordpress.org/support/topic/difference-between-query-and-wp-admin-page/#post-18673858)
 * I figured out the problem
 * freshness is the answer.
 *  Plugin Author [Hector Cabrera](https://wordpress.org/support/users/hcabrera/)
 * (@hcabrera)
 * [8 months, 1 week ago](https://wordpress.org/support/topic/difference-between-query-and-wp-admin-page/#post-18673904)
 * That, and also:
    - Your cwpai_get_popular_posts_ids_weekly() function (that’s such a long name
      haha) is caching data for 12 hours whereas the Stats screen is showing live
      data so that alone will cause a mismatch; and
    - Your cwpai_get_popular_posts_ids_weekly() function is also excluding the following
      IDs from the list: 16817, 6620, 77812, 22232, 39656. This too will make a 
      difference.
 * Hope that helps. Please feel free to let me know if you have any other questions.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Difference between query and wp admin page’ is closed to new replies.

 * ![](https://ps.w.org/wordpress-popular-posts/assets/icon-256x256.png?rev=1232659)
 * [WP Popular Posts](https://wordpress.org/plugins/wordpress-popular-posts/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wordpress-popular-posts/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wordpress-popular-posts/)
 * [Active Topics](https://wordpress.org/support/plugin/wordpress-popular-posts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wordpress-popular-posts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wordpress-popular-posts/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Hector Cabrera](https://wordpress.org/support/users/hcabrera/)
 * Last activity: [8 months, 1 week ago](https://wordpress.org/support/topic/difference-between-query-and-wp-admin-page/#post-18673904)
 * Status: resolved