Wpdb generates too many queries
Wpdb generates too many queries
Wpdb generates too many queries
For this you can use WP_Comment_Query. The query will be $comments_query_args = array( ‘post_type’ => ‘post’, ‘number’ => 5, ‘status’ => ‘approve’ ); $comments_query = new WP_Comment_Query(); $recent_comments = $comments_query->query($comments_query_args);
That’s a lot of queries! Have you considered running the query once and using something like mixitup or isotope to sort your results?
Turned out to be interference from another Flatpack hack I had in place to stop it displaying child CPTs when outputting its widgets. For reference, the damage was being done by a pre_get_posts hook. Worth checking this if you’re similarly stuck.
Your SQL dump proved to be informative.. Either 1=2 or 1=0 in a SQL statement means something you passed your WP_Query was invalid. It appears that in your tax_query you specified ‘field’=>’term_id’, which isn’t a valid option – it should be just ‘field’=>’id’.
try this: Put this code in your search form: <form method=”get” id=”searchform” action=”<?php bloginfo(‘url’); ?>/search”> <?php $args = array( ‘public’ => true, ‘_builtin’ => false ); $output=”objects”; $operator=”and”; $taxonomies = get_taxonomies( $args, $output, $operator ); $my_tax_array = array(‘your_taxonomy_name1′,’your_taxonomy_name2′,); //make array of your taxonomies echo “<select id=’my_select_taxonomy’ name=”my_select_taxonomy”>”; echo “<option value=”0″>—-</option>”; if ( $taxonomies ) { … Read more
If you store the meta as a serialized array, you should do meta query like this: $args = array( ‘post_type’ => ‘income’, ‘meta_query’ => array( array( ‘key’ => ‘income_dates’, ‘value’ => “2014-02-01”, ‘compare’ => ‘LIKE’ ), ) );
$wpdb: how to use a query as a base for another query?
You could use has_term Codex, like the following code: if( has_term( ‘jazz’, ‘genre’ ) ) { echo ‘This is something…’; } Remember to add the third parameter – $post (int or object), if it’s not in the loop.
Query custom post type by date field only working when two posts match the query