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' => 'category',
'field' => 'id',
'terms' => 1 //put your term id here
),
array(
'taxonomy' => 'category',
'field' => 'id',
'terms' => 2 //put your term id here
),
array(
'taxonomy' => 'category',
'field' => 'id',
'terms' => 3 //put your term id here
)
);
$query->set(
'post_type', [ 'libri', 'post'],
'tax_query', $tax_query
);
Related Posts:
- How to get an array of post data from wp_query result?
- How to only display posts whose meta_value field is not empty?
- How to print the excuted sql right after its execution
- Is it possible to completely stop WP_Query retrieving posts?
- How to add taxonomy filter on the query fly?
- Pagination returns 404 after page 20
- Make a WP Query search match exactly the search term
- Make loop display posts by alphabetical order
- Displaying several specific pages using WP_Query()
- post_type is ignored by WP_Query when ‘tag’ argument is included
- How to query posts of standard post format. For real
- Orderby menu_order doesn’t work
- WP_Query by Category Name
- WP-CLI How to generate a list of posts with corresponding meta values
- Warning: urlencode() expects parameter 1 to be string, array given
- WP_Query OR clause for tax_query and keywords
- All sticky posts are returned in custom query
- Transient pagination not working properly
- query posts in functions.php and update a field
- get_posts() seemingly ignoring post_type
- If orderby parameter using pre_get_posts is the same for multiple posts what fallback does the query use?
- Can not switch the queried post in pre_get_posts hook
- Which filter/action hook gets triggered after a query has been performed?
- Why use JSON API to display recent posts?
- Why query_vars get altered in WP_Query Object?
- pre_get_posts filter meta_query without conflicting existing meta_query
- Get list of terms that have posts in another term
- Get data of all posts of a query before pagination
- WP Pagination on Posts Search Results Page resulting from AJAX WP Query
- How to avoid wp_query returning the same post I’m on in results?
- Custom query for sidebar isn’t returning results
- How to vary post loop results layout and resume?
- Adding an array from a query string to a WP meta_query
- WordPress add_rewrite_rule() cannot visit lower url levels
- WordPress Loop and $post
- How can I create ‘future’ and ‘past’ parameter for restAPI by filtering the CPT custom date field by greater than / less than current datetime?
- WP_Query tax query part of slug
- Query posts without meta preload
- How to implement a new row_count method in WordPress?
- Some doubts about how the main query and the custom query works in this custom theme?
- How to do a wp_query with two acf-fields, sorting on one of them
- Using Advanced Custom Field for file upload, how do I load the file url
- Retrieve posts using thumbnail id as meta key
- Shortcode for latest -not expired- posts
- WP_Query – Object manipulation vs WordPress functions
- Only display post if published in last 24 hours?
- Transients with dynamic WP_Query
- How to remove the most recent post from $the_query
- WP_Query loop else statement not executing
- Modify Search Query if original Query gave no results
- How to cache wp_query with pagination using transients?
- Problem with WP_query
- Why is WP_Query not displaying expected data?
- Filter post query to only show direct children of category
- Selecting posts with a given meta value for a meta key
- Get every post with value in meta key
- pre_get_posts – editing query, tax_query
- Check if a post has term inside loop
- Display all posts in a custom post type, grouped by a custom taxonomy. How to sort the posts alphabetically and the terms by ID?
- How do I add a relation parameter to my filter query?
- Hacking ‘posts_per_page’ in WP_Query
- How to get posts by category and by choosing a taxonomy term?
- Query outputting YouTube url rather than embedded video
- Paginate pages with dynamic query
- WP_Query loop doen’t work with my custom taxonomy
- wp list pages using meta box value
- get_var is neither a string, integer, or array …?
- Deleting terms from the WordPress wp terms table
- Can I get one wp_query to double order like this?
- In a WP_Query can I force the results’ is_singular() to be set to false?
- Sort custom post by custom field if none order by latest release
- Order (by ASC) posts with meta_key so posts without values are last
- how to include orderby value that is empty?
- Why can my filter query SOME metadata but not other metadata?
- WordPress Carousel with recive posts (Bootstrap)
- Custom query showing all acf field values instead of the one searched
- Pagination Shows Up But Won’t Work on Custom Gallery Page
- How can I use WP_Query to sort ‘event’ custom post type by date?
- posts_per_page in a tax_query
- Modify a query with no results in pre_get_posts
- WP_Query: custom orderby (not ASC nor DESC)
- Show posts from categories instead of tags
- Sorting Posts by Taxonomy thats not within the query’s $args
- Orderby query does not work for custom fields even with meta query
- Querying posts with meta key and meta value not returning anything
- Set Transient on CPT
- Why is $wp_query fetching nothing?
- How to query post into a complex slider
- Horizontally paginate through sets of blog posts?
- WP_Query Sorting Posts by month … timeline effect
- Comments orderby comment date not working
- Switched from query_posts to wp_query, pagination no longer working
- When importing a database any page with a wp_query in doesn’t work
- My class function is not seeing GET url paramaters
- Adding css tweak based on page template
- Why wp_query return 1 row if i have 3 row pass in it
- Filtering product search results using tags
- Woocommerce set loop_shop_columns to be 3 in the main shop page loop only and 4 otherwise
- Get posts using multiple values from ACF checkbox as meta query wordpress
- Why ignore_sticky_posts argument is in sticky post query?