WordPress search WP_Query to cover multiple post types and their custom fields?

Found a way to combine WP_Query posts: $query1 = new WP_Query($args); $query2 = new WP_Query($args2); $query3 = new WP_Query($args3); $combined = new WP_Query(); $combined->posts = array_merge( $query1->posts ,$query2->posts ,$query3->posts ); Still not as elegant as doing one WP_Query with all those conditions in args being an OR … as in the query should match ANY … Read more

Isn’t Returning Value While Using SELECT COUNT(*) FROM {$wpdb->prefix}

$combined_views = (int)$get_visit_query + (int)$offset; This doesn’t make much sense. $get_visit_query is a string (your query). Converting it to int returns in 0, see this snippet. Instead it should be $combined_views = (int)$visits_total + (int)$offset; Sidenote: Are you actually hooking the function via add_filter()? If not, apply_filters(‘get_post_views’, ..) will not have the desired effect. Using … Read more

Why my query is not “Main_query”?

And the anwser to my question: Don’t make new WP_Query object. Don’t try to overwrite main query. Use global $wp_query; In my example the function should be like this: public function askanban_display_board(){ global $wp_query; $wp_query->set(‘post_type’, ‘ticket’); $wp_query->set(‘posts_per_page’, -1); $posts = $wp_query->get_posts(); print_r($posts); }