Wednesday, November 16, 2022
HomeWordPress Developmentwp question - Customized Wp_query loop takes very lengthy

wp question – Customized Wp_query loop takes very lengthy


I’ve bought a easy customized WP_Query on a customized submit kind web page that reveals a group of posts:

$t_query = new WP_Query($filters['filtered_args_for_query']);

$wpdb->last_query outputs:

SELECT post_id, meta_key, meta_value FROM wp_postmeta WHERE post_id IN (203046,205067,205540,206297,207374,207391,207996,209090,210979,211141,211153,211166) ORDER BY meta_id ASC

Each time I place a easy Loop into my template, it takes 9 seconds to course of the web page (in any other case, 1 second):

if($t_query->have_posts()){
   whereas($t_query->have_posts()){
      $t_query->the_post();
   }
}

There are some 60 000 posts and 250 000 meta entries in my database. BUT, on different pages (class pages), which have the identical customized question, my server serves pages in only a second or so. There, $wpdb->last_query returns:

SELECT post_id, meta_key, meta_value FROM wp_postmeta WHERE post_id IN (187887,189775,189853,190680,192412,196893,215373) ORDER BY meta_id ASC

To me, they each appear just about alike.

Can somebody inform me what makes such a distinction, or the place to look? There have to be one thing within the Loop that makes the distinction, for the reason that pages for the customized submit kind and the class load simply the identical after I take away the Loop, and since (for debug functions) my Loop would not do something besides getting ready posts.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments