Help With issue on pre_get_posts filter in taxonomy

Solved! I was using the wrong technique to create a custom query to my taxonomy instead of using the function above I create new function that use query_vars. Here is the code function taxonomy_posts_order($query) { global $browsetype; $term = get_term_by( ‘slug’, get_query_var( ‘term’ ), get_query_var( ‘taxonomy’ ) ); if ( $query->query_vars[‘taxonomy’] == $term->slug ) { … Read more

Meta Query “IN” doesn’t work with ACF checkbox filter

Checkbox field is stored as serialized array, therefore you can not use the IN operator and array with the values you are looking for. To get posts with checked “melbourne”, change meta_query to: $meta_query = array( array( ‘key’ => $name, ‘value’ => ‘”melbourne”‘, ‘compare’ => ‘LIKE’, ) ); To get posts with melbourne or sydney: … Read more

Multiple Values stored as array in Meta Query

An IN query is not a string comparison query. It is more like a bunch of OR statements. … WHERE tablename.animal IN (‘cat’,’dog’,’ferret’) is going to be the same as …WHERE tablename.animal=”cat” OR tablename.animal=”dog” OR tablename.animal=”ferret” $_POST[‘_casestudypost’] is going to be an array, and if you stored it as a single value in postmeta it … Read more

How do I create my own nested meta_query using posts_where / posts_join?

Here is a rough outline of how you’d go about making a UNION work with WP_Query. add_filter( ‘posts_request’, function ($clauses) { $clauses = str_replace(‘SQL_CALC_FOUND_ROWS’,”,$clauses,$scfr); $scfr = (0 < $scfr) : ‘SQL_CALC_FOUND_ROWS’ : ”; $clause2 = $clauses; // manipulate this return “SELECT {$scfr} u.* FROM (({$clauses}) UNION ({$clause2})) as u”; }, 1, 2 ); Set up … Read more