wp_query with meta_query and tax_query
wp_query with meta_query and tax_query
wp_query with meta_query and tax_query
Answering your second question – yes, it is possible, you can use tax_query for this, for example, this query will get all posts that has any term of ‘flowers’ taxonomy AND ‘colors’ taxonomy: $query = new WP_Query( array( ‘post_type’ => ‘custom-post’, ‘posts_per_page’ => 5, ‘order’ => ‘DESC’, ‘tax_query’ => array( ‘relation’ => ‘AND’, // it … Read more
So! I solve this situation with: wp_set_post_terms. I iterate my posts and for each one wp_set_post_terms make that part. See here: https://developer.wordpress.org/reference/functions/wp_set_post_terms/ Now I have my categories from wp and my customs post with his own categories.
Depending on use case scenario you might need to write some custom code or a tiny plugin to achieve this. If you want to filter the posts in admin dashboard post list then you can use following code snipped to jump start <?php if (is_admin()){ //this hook will create a new filter on the admin … Read more
Tax query get first product with attribute value in pre_get_posts
I was building something similar a couple of years ago, here’s what I did, maybe it helps … (changed to your use case) $result = new WP_Query([ ‘post_type’ => ‘location’, ‘orderby’ => ‘name’, ‘order’ => ‘ASC’, ‘posts_per_page’ => -1, // all of them on one page ‘tax_query’ => [ [ ‘taxonomy’ => ‘services’, ‘field’ => … Read more
Add terms to a taxonomy archive from within the same taxonomy
How to do a WP_Query when a post has a relationship to anoter post via an ACF Post Object field, where the related post is in a certain category?
After messing with some code I found a solution: just use this code and a lot if information will be showed. Within all this data you search for the categorie that is inside your taxonomy and you’ll see the taxonomy-> name. // Show all data of all taxonomies function print_tax_data(){ $data = get_terms(); print_r($data); } … Read more
Query Two Different Taxonomies Nested