in tax_query this Is the code correct? I need to access beginner video posts for different subject

try this.. $args = array( ‘post_type’ => ‘videolesson’, ‘ordeby’ => ‘rand’, ‘order’ => ‘DESC’, ‘posts_per_page’ => 8, ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘level’, ‘field’ => ‘slug’, ‘terms’ => ‘beginner’, ‘compare’ => ‘IN’, ), array( ‘taxonomy’ => ‘subjects’, ‘operator’ => ‘EXISTS’ ) ), ); $getting = new WP_Query( $args );

Showing most popular post of week

This is not how you collect view stats over period of time. The right way to do it is to have some sort of sliding window that will help you calculate views over specific time frame. For example to get the most popular post “today” you store the counts in an option, and zero the … Read more

Speed up WP_query with meta comparing dates

Can you upgrade your hosting? I’ve had a very similar query running on AWS that is fine with 1700 events and meta_query that also had location. Another option for you (if it’s always the same query i.e. today as your queried date) is to use transients to store the result. $events_arr = get_transient(‘events_running_today’); if (!$events_arr) … Read more

Updating an intensive wp_query result once daily

I am using transients for this scenarios. Result is saved to database (wp_options table) with expiration set. It’s usable if the slow load time is below some reasonable treshold … one (first) visitor will have to wait that long to render his request, every other will see saved result. $results = get_transient(‘my_results’); if( ! $results … Read more

post_type not working when tag__in is present?

This is not a bug that I have heard of so I would make sure you do not have a plugin or some other code filtering pre_get_posts. I would recommend checking the SQL that is run to try and debug. $query = new WP_Query($args); echo ‘<pre>’; var_dump($query->request); echo ‘</pre>’; Using that you can verify if … Read more