How can I get all the posts that are related with a specific taxonomy term?
Try this: ‘tax_query’ => array( ‘origin’ => ‘English’ ) Also, it should be pretty easy. Do some research.
Try this: ‘tax_query’ => array( ‘origin’ => ‘English’ ) Also, it should be pretty easy. Do some research.
The reasons your pre_get_posts filter does not work on the widget are the condition !$wp_query->is_main_query() makes the filter handle only the main query and nothing else Your special parameter myattr is “self populating” only on the main query but it is not propagating automatically to other queries. To make it work on the widget, the … Read more
Performance of wp_get_attachment_image_srcset() and wp_get_attachment_image_url()
You can use the $wpdb object // Print last SQL query string $wpdb->last_query or: <?php if (current_user_can(‘administrator’)){ global $wpdb; echo “<pre>”; print_r($wpdb->queries); echo “</pre>”; }//Lists all the queries executed on your page ?> You might have to set define(‘SAVEQUERIES’, true); in wp-config.php
Actually there happens more than single query behind the scene. They are both for getting some needed data and also for updating or creating or inserting data. Say for post terms wp_insert_post() get those data by query. So, where you’re assuming that it should run 40,000 query it actually run more than that. Please have … Read more
PHP function http_build_query(); would return different string for this array. It won’t remain readable like an array but, I believe, it will work as parameter to WP_Query. build_query is the WordPress equivalent for the same functionality. Turns out that build_query is a bit different from http_build_query. http_build_query returned date_query%5B0%5D%5Bafter%5D=24+hours+ago and build_query returned date_query%5B0%5D%5Bafter%5D=24 hours ago. … Read more
You should not be using query_posts() for this or anything else. For secondary loops you should be making new WP_Query instances. Since you can (and should) assign instances to different variables they won’t interfere with each other. So your structure would be roughly like this: $outer_query = new WP_Query(); while( $outer_query->have_posts() ) : the_post; $inner_query … Read more
Here is the tested solution- // Your sample array $sample_array = array( 0 => array( ‘meta_key’ => ‘cpf_first_name’, ‘meta_value’ => ‘John’ ), 1 => array( ‘meta_key’ => ‘cpf_first_name’, ‘meta_value’ => ‘James’ ), 2 => array( ‘meta_key’ => ‘cpf_first_name’, ‘meta_value’ => ‘Jane’ ), 3 => array( ‘meta_key’ => ‘cpf_gender’, ‘meta_value’ => ‘Male’ ), 4 => array( … Read more
pagination for a custom query
How to reduce the load / no of queries on MySql Database