In the list view, I want to create a list in which regular posts and multiple custom posts are mixed, but I want to exclude only some of the terms from the list.
<? php $paged = get_query_var ('paged')? get_query_var ('paged'): 1; $args = array ( 'post_type' =>array ('post', 'event_info', 'hoge_info', 'fuga_info'), // Specify multiple custom and regular posts 'paged' =>$paged, 'order' =>'DESC', 'posts_per_page' =>-1, 'tax_query' =>array ( array ( 'taxonomy' =>'event_detail', // Specify taxonomy 'field' =>'slug', 'terms' =>'event-post', // specify terms 'operator' =>'NOT IN', )) ); $query = new WP_Query ($args); ?>
I want to exclude the term event_post from the event_detail taxonomy in the custom post type event_info.
If i set 'post_type' to single instead of multiple, the specified term will not be displayed, but if you specify it with array, it could not be used.
What is the correct way to write?
Answer # 1
It may not be a direct solution,
post__not_inMay be used.
It is a method of specifying and excluding the post ID as follows,
Get the ID of the term "event_post" of the "event_detail" taxonomy of the custom post type "event_info" in advance as an array,
post__not_inIs used to specify
'post__not_in' =>array (1, 2, 3), // display posts that do not include the array post ID
'operator' =>'NOT IN',Hopefully this will be a good alternative if you can't proceed with this approach.
Answer # 2
It was a very blind spot, but in the case of a post marked "fixed at the top," it seemed to get past this tax_query, and those not fixed at the top were properly excluded.
So, use post__not_in which was answered (How to use is completely different, but w)
'post__not_in' =>get_option ('sticky_posts'), // exclude posts fixed at the beginning
Was added to the source and was successfully excluded.
We hope you find it helpful and help someone who is stumbling.
- php - i want to put multiple custom taxonomies, but they are not reflected
- php - about the multiple structure of laravel's many-to-many relations
- php - wordpress custom taxonomy cannot be saved/selected as a tag from the article posting screen of the management screen
- i want to get the value of where specified in the query builder in cakephp3
- php - how to refine your search for custom posts
- php - i don't see my custom post
- php - [laravel 6] cannot implement multiple tag search function
- php - sessions that prevent multiple posts do not work
- php - multiple thumbnail sliders are installed and move together
- php - i want to output 2 new articles of custom post type in the form of contact form 7
- php - i want to sync my custom post archive page with my widget's calendar
- php - i want to extract the laravel zip file to the specified path
- php - i want to display checkbox items for custom fields
- php - i want to sort a custom field of numbers with commas in wp_query without commas
- php - i want to get data via multiple tables in laravel
- php - wordpress: tab switching using custom field items
- php - custom post page in wordpress oh, can i have a fixed page as a parent?
- php - i want to display the value of a custom field as a column in the wordpress custom post list
- php : WordPress Taxonomy Output Limit
- php : Remove a tick with top-level categories
- php : Who can vitely show how to assemble an array of data from users and pass it into a variable?
- php : Stylization Select WooCommerce Crab Products
- php : WooCommerce Assign Template for subcategories
- php : CONTACT FORM 7 does not display notifications when sending a letter