Get access to all terms associated to each post that the wp_query loop displays

If I understood you correctly, you are looking for get_the_terms(), which.. Retrieves the terms of the taxonomy that are attached to the post. You could for example have helper functions like these, // functions.php function my_sports_post_terms( int $post_id ) : array { $taxonomies = [‘basketball’, ‘volleyball’, ‘baseball’]; $terms = []; foreach ($taxonomies as $taxonomy) { … Read more

Custom Wp_query loop takes very long

I found a solution to my question. I used the following code: global $wpdb; if($t_query->have_posts()){ while($t_query->have_posts()){ $t_query->the_post(); echo $wpdb->last_query.”\r\n”; } } and it showed there was an action somewhere hooked to the_post hook, sending requests to update some meta every time a post was processed. So, the answer to my question is: I should have … Read more

wp_query loop with compare operator simply not working, why?

As stated in the documentation: (bold formatting was added by me) Note that meta_query expects nested arrays, even if you only have one query. So your meta query should actually look like the following, and note that in a meta_query, we don’t use the meta_ prefix, e.g. we use just key and not meta_key: $query_args[‘meta_query’] … Read more

How does ‘category__not_in’ differ to cat => ‘-1’?

Looking at the codebase, the only difference appears to be that category__not_in excludes child terms from selection, whereas cat does not. Should category__not_in be used with caution, similar to posts__not_in? Absolutely, but for different reasons. The main issue with excluding posts is that it causes problems for caching – every query with a different excluded … Read more

Elementor custom query

This just requires adding additional parameters to the query->set() array… …it’s standard WP_Query() stuff. So you’d essentially be taking this line: $query->set( ‘post_type’, [ ‘libri’, ‘post’] ); …and expanding it to include a tax query… $tax_query = array( ‘relation’ => ‘OR’, //can also use ‘AND’ depends how you want it to work array( ‘taxonomy’ => … Read more