wp_reset_query();
wp_reset_postdata();
$post = null;
$course_args = array(
'post_status' => 'publish',
'post_type' => 'course',
'posts_per_page' => 5,
'order' => 'DESC',
'orderby' => 'date',
'tax_query' => array(
array(
'taxonomy' => 'course_cats',
'terms' => array($category_id),
),
),
);
$course_args['meta_query'] = array(
'relation' => 'AND',
array(
'key' => 'type',
'value' => array('type1'),
'compare' => '=',
),
);
$query_courses = new WP_Query($course_args);
Request "SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) WHERE 1=1 AND ( wp_term_relationships.term_taxonomy_id IN (1835) ) AND ( ( wp_postmeta.meta_key = 'tip_kursa' AND wp_postmeta.meta_value = 'paid' ) ) AND wp_posts.post_type = 'course' AND ((wp_posts.post_status = 'publish')) GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 1"
I have disabled all plugins except ACF, it is filtered by its field. Disabled function.php and all the extra code.
get_posts
call in that code, can you provide more context? What's the purpose ofwp_reset_query
and where is the pagination code? Do you havepre_get_posts
filters? The query in the question does not specify a page, and it looks like you have atype
meta field that would be better as a custom taxonomyget_post_meta
etc super fast, but searching for posts gets slower as the size of the meta table increases. Can you answer my other questions? It's unclear where this code runs, the URL and template this code is in, as well as what the code for the loop that displays the courses looks like. Also you said there is no pagination in your comment, but your question mentions different pages in its title can you explain?$category_id
come from?