How do I add a relation parameter to my filter query?

Each of your code blocks will overwrite the previous, you need to add to the array rather than replace it: $args[‘tax_query’][] = array( ‘taxonomy’ => ‘region’, ‘field’ => ‘id’, ‘terms’ => $_POST[‘region_filter’] ); relation is AND by default, so you can just omit it, but if you wanted to explicitly set it: $args[‘tax_query’][‘relation’] = ‘AND’;

WP_Query returns no posts for category

The issue turned out to be custom post types. Even though a custom post type produces posts, WP_Query() doesn’t select them unless specifically coded to do so with ‘post_type’ => ‘slug’, in the query arguments.

Sort posts in a specific way

This is possible with native query parameters like this: $posts = get_posts([ ‘post__in’ => [2,5,3,1,4,6], ‘orderby => ‘post__in’, ]); This combination will instruct WP to fetch specific posts by ID and order them in the specific way that you supplied IDs.

Cannot get custom posts by category

You can try using cat or category__in (for array of categories) instead of category-name and assign an ID to it: $args = array( ‘posts_per_page’ => 6, ‘post_type’ => ‘albums’, ‘cat’ => 4, ); I also would use single quotation ‘ instead of double quotation ” while setting a value. You are also missing quotations around … Read more

Grabbing taxonomy terms and inserting them into an array

This creates the multidimensional array in advance and then assigns it to options. The multidimensional array is created by assigning an array to each element of the main array. I have reused the $feat_pages_terms variable, but you can also create a separate variable using array() and assign array elements to that, I am including those … Read more

WP_Query by keyword OR post tag

Depending what you want to achieve, the most simple way taken from WordPress documentation looks like below. Displays posts tagged with “bob”, under “people” custom taxonomy: $args = array( ‘post_type’ => ‘post’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘people’, ‘field’ => ‘slug’, ‘terms’ => ‘bob’, ), ), ); $query = new WP_Query( $args ); Check … Read more

Display all posts in a custom post type, grouped by a custom taxonomy. How to sort the posts alphabetically and the terms by ID?

I think you need first to sort the genre terms in the other query: $genres = get_terms( ‘genre’, ‘orderby=term_id’ ); And then on the posts query for each genre (like Chip Bennet’s approach): $member_group_query = new WP_Query( array( ‘post_type’ => ‘member’, ‘orderby’ => ‘name’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘member_group’, ‘field’ => ‘slug’, ‘terms’ … Read more