Operator ‘AND’ in the get_posts() function’s tax_query terms not working

Try adding include_children parameter as false to your first example (tested): $args = array( ‘post_type’ => ‘workshops’, ‘posts_per_page’ => -1, ‘fields’ => ‘ids’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘workshop_categories’, ‘field’ => ‘slug’, ‘terms’ => array( ‘crafts’, ‘jewellery’ ), ‘operator’ => ‘AND’, ‘include_children’ => false, ) ) ); $posts = get_posts( $args ); Unfortunately I … Read more

Querying by post category slug with core/query block markup

You should not modify the taxQuery value, or that it should always be in the form of {“<taxonomy>”:[<term IDs>],”<taxonomy>”:[<term IDs>],”<taxonomy>”:[<term IDs>],…}. But you can add custom arguments, so “categoryName”:”news” is good. And then you can use the query_loop_block_query_vars filter to add the category slug to the WP_Query arguments coming from the Query Loop block. Here’s … Read more

Complex Taxonomy scheme

Set your system up like this: locations – CPT administrative – hierarchical taxonomy natural – hierarchical taxonomy type – non-hierarchical taxonomy In the administrative taxonomy, you would create your tree: countries on the first level, regions second, departments and so on. Then, you would assign your locations to the smallest administrative denominations among your taxonomies … Read more

Custom query for certain post type OR another post type with a certain category

First, take a look at this: https://developer.wordpress.org/reference/classes/wp_query/ You can filter by querying by post type, or in a single query (code between /* */). <?php //This is the first query $query_A = array( ‘post_type’ => ‘post_type_A’, ‘post_status’ => ‘publish’, //’cache_results’ => true, ‘posts_per_page’ => 10, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’, ‘fields’ => ‘ids’//add by … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)