meta_key and meta_value not working together

You could try this: $args = array( ‘post_type’ => ‘cqpp_interventions’, ‘posts_per_page’ => ‘-1’, ‘meta_query’ => array( array( ‘key’ => ‘priority’, ‘value’ => ’80’ ) ) ); The real issue with your query is because you are passing meta_key and meta_value. However, the arrays in your meta_query argument should have the keys key and value instead. … Read more

Intentionally exceed max_num_pages on main query without getting 404?

On every page load, WordPress executes these functions in their respective order: init(); parse_request($query_args); send_headers(); query_posts(); handle_404(); register_globals(); where the main query is finished after query_posts(). Note that in this point in time, WordPress knows the template AND all the query variables like max_num_pages. In handle_404(), if the main query has any posts, the function … Read more

tax_query shows no results if nothing is selected

So far good, add taxonomy condition by checking the suburbs and states Value. // Suburbs if( !empty( $_GET[‘suburbs’] ) ) { $suburbs = $_GET[‘suburbs’]; } // States if( !empty( $_GET[‘states’] ) ) { $states = $_GET[‘states’]; } // Query arguments. $args = array( ‘post_type’ => ‘properties’, ‘posts_per_page’ => 10, ); $taxquery = array(); // if … Read more

How to detect custom query inside `posts_where` hook?

If we have the query arguments like this $args = array( ‘queryid’ => ‘blackjack’, … ); $q = new WP_Query( $args ); Note we added one custom query argument that is not officially present in here. Now we can identify the exact query by that queryid if we use the second parameter of the posts_where … Read more

How to show only one post for each categories of taxonomy of custom post that contains a specific custom field

<?php // get all terms of the `bank` taxonomy $banks = get_terms( array( ‘taxonomy’ => ‘bank’, // more arguments can be used, see (1) below the code ) ); // look through banks, picking one post from each foreach ( $banks as $bank ) { $args = array( ‘post_type’ => ‘account’, // your custom post … Read more

Finding post content that begins with a specific character

Something like this will probably work: $results = array(); $allPosts = get_posts(‘post_type=post&numberposts=-1’); foreach ($allPosts as $aPost) { if ( substr($aPost->post_content, 0, 1) == ‘<‘ || substr($aPost->post_content, 0, 2) == ‘<a’ ) $results[] = $aPost->ID; } echo “<pre>”.print_r($results,true).”</pre>”; UPDATE: but you should revisit the MySQL approach in the links you provided. This php method is somewhat … Read more