Note that if you have the post slug, you don’t need the additional taxonomy query to find that post, so it makes sense to drop the expensive taxonomy query in core in that case.
Otherwise you could try instead the post_name__in
parameter:
[
'post_name__in' => [ '<postslug>' ],
'tax_query' => [
[
'taxonomy' => '<taxonomy>',
'field' => 'slug',
'terms' => <slug>,
'operator' => 'IN'
]
],
];
that was introduced in WordPress 4.4, if you really want the taxonomy query part included as well 😉
Related Posts:
- Get Posts Under Custom Taxonomy
- Get Posts Under Custom Taxonomy
- Displaying the category name of a custom post type
- Show WordPress Custom Taxonomy Items Based On a Selected Item From Another Custom Taxonomy
- How to know if get_posts() failed?
- Adding Multiple Values to a Post Meta Key
- How do I get the slug of a custom taxonomy category of a post?
- How can I add a meta-box to the posts editor containing all items of a custom taxonomy as checkbox?
- Get Posts via Taxonomy Term Name with Space
- Choose whether to automatically add a taxonomy with the same name as the post
- Posts list in custom taxonomy
- How can I setup a relationship using categories in WordPress?
- How to get posts and comments amount per hour, per year and per month?
- Why posts array is empty?
- How to give classname to post if post has no content?
- Related Posts function not working
- How to associate a custom taxonomy to a post multiple times
- Query to fetch custom taxonomy along with post title
- Customizing URL slugs of Custom Post Type and Taxonomy make posts/pages 404
- How to get post count including nested categories
- Custom Taxonomy From Database
- Displaying Results From Custom Taxonomy Query
- Multiple loops on a Search result page?
- Special Query: Title, Terms, Content – %LIKE%
- Querying posts from current category, using a variable as array argument
- wordpress display posts by terms id or name
- Query posts from newest category
- How to convert return type of ‘get_posts()’ same as ‘wp_get_recent_posts()’?
- Filter By Term Not Working – Custom Post Type
- How to get all posts in gallery post format template
- How can I get all the posts that are related with a specific taxonomy term?
- My custom query is displaying random posts in random order
- Sort Events by Venue Title – Sort Post set by related post ids
- Multiple Custom Post Type loop logic
- wp query custom orderby not custom field
- Any difference betweenn posts and pages for one page?
- Query post for today, if no post get the previous one
- Custom Select Query pagination not working properly
- Query post by meta key of another table
- Sort / Filter Queries
- How to list all names and descriptions of a custom taxonomy
- How to get the current user post and it’s ID?
- Query post category & remove any post id
- How to display term in archive page?
- Display the latest post from some selected authors
- Advanced Post Display/Pagination/Ordering
- How can add posts without category into category
- Ordering posts alphabetically by meta keys and title
- Why I obtain this WP_Query strange behavior trying to select posts having a specific tag?
- Why I have this strange behavior when I try to exlude the featured post from posts visualization?
- Can I use multi (sub) levels of relation (AND | OR) on custom query?
- Grab next post title in archive page
- Removing a post from the results of a WP Query
- Custom taxonomy – query returns an error
- Query posts from a specific category and selected tag
- Continuous listing from a custom field
- 404 for some custom taxonomy not ALL taxonomy
- Query Only Show Text on Posts With Certain Taxonomy Tag
- How to perform a search inside a specific taxonomy category
- Retrieve latest post by multiple categories with ID
- External link not showing on post but showing on comment
- Sort post by category using HTML Select tag
- How to store post rating system data post independent?
- How to get all the terms of a post
- How do I paginate posts page with $wpdb?
- Get first comment link on the post itself
- WP_Query retrieve custom posts but not the post showing
- How to get all post titles starting with numbers and symbols?
- Bulk Attach Or Insert Media To Post Without Opening Post Editor
- Creating pages and getting their values from the database table
- Make division in post_query?
- How to limit post query to only return a total count of items with certain post statuses?
- display post according to the term
- Displaying posts on Homepage
- How to get single post by one author?
- retrieve post slug by post_tags taxonomy
- Load posts from external source if not found in database
- Display one post randomly from category on home page
- get_posts includes “auto drafts”?
- Taxonomy Category category.php not working
- wordpress show category link instead of post link [closed]
- How to set value in Query Loop?
- Wp_query WooCommerce products
- tax_query not working properly with get_posts
- query grandchildren taxonomy terms
- posts_per_page – Repeats only first posts ‘post__in’ array
- The page that displays Posts on homepage
- query_post or single-[cpt].php?
- append $_GET parameters to post
- NewsPaper WP Theme – Additional Related Posts Filter by Time (divTag composer)
- Word count for all posts of all authors
- Need to show birthday of custom post type(Famous people in this case) in elementor. Date of birth set in custom fields
- View post with specific category id and name which I selected in the backend (drop-down option)
- Display posts with id equal to relationship value
- How to make ‘show_option_all’, that comes from wp_list_categoreis, to work with get_categories or with get_terms?
- Filter/Sort Post Form On Taxonomy page
- Sort Posts Alphabetically Based on Specific Category (Divi)
- Three different queries on same page
- Change permalinks in posts via SQL
- Translation related post text to Arabic