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%
- Should we trust the post globals?
- get comments and get posts in loop
- How to get previous 10 days post from a specific date – WP Query
- Duplicate posts
- Looping through posts per category gives same posts for each category
- How to show posts rank based on custom field value
- How do I create Comma Separated list of attached image ids?
- get_terms parent for current product only
- Show the author’s count of total amount of posts assign to a custom taxonomy term
- Redirection to taxonomy posts list after post submit.
- Remove custom posts that match taxonomy value
- Check if post exists
- How Can i Get 5 Recent Post Title With Corresponding Link?
- Can I set and show “important” post in my blog?
- How to set up multiple taxonomies for groups of posts
- Avoid duplicate post from same Taxonomy
- WP_Query Authors OR Categories
- Set terms in a custom post
- Pass data between pages
- Why is querying posts messing up my pages?
- Get related posts of child term of custom post type
- Insert Content In Between Post Feed
- How to bulk-untag multiple posts?
- get the taxonomies terms associated with users
- Pagination with an array of post objects?
- get query() without post content?
- How can I hide tags on a child-category page, if that tag has not been used?
- posts_per_page option limits the number of Gallery items
- Custom Taxonomy with tax_query
- Posts loop displaying the same post data
- How do I insert a post with custom post type and relate it to a custom taxonomy?
- Dynamically switch template on click
- Get all custom post types excepted some…
- Counter is skipping post when I still want it visible [closed]
- Do not show children of a category
- Display posts of specific category term
- How to get post content from an array of ids?
- How to get all post_parents of a post?
- Run query_posts if SESSION is empty?
- Custom Articles page only showing a limited number of posts per page
- Programatically adding custom filters to post list
- How to retrieve certain number of images from a wordpress post?
- How to convert query sql to shortcode in wordpress?
- Get x recent posts by author?
- Some doubts about how the loop work (trying debugging it)
- Custom taxonomy query showing more than 4 posts
- List latest posts with least comments in WP-Admin
- Adjust the order for returned posts
- Trim posts from WP-Query?
- Trying to exclude custom posts based on date, while sorting by custom field
- How to Rearrange WordPress Tags list on frontend using Shortcode with specific order?
- how to add tags to post in the Loop?
- Merge get_comments & get_posts into a single query
- How to optimize posts query in wordpress
- How to search through “post title” and “tags” using WP_Query?
- Need to display a Jan 1st post as the site’s front page on Jan 1st, and Jan 2nd post as front page on Jan 2nd etc
- Taxonomy checkboxes not showing current status on edit page
- Bulk Post update_post_meta
- Slug collision between page, taxonomy and custom post type
- Numbering author posts in posts query
- How to run select query of post with category and tags?
- Filter By Term Not Working – Custom Post Type
- My custom query is displaying random posts in random order
- Any difference betweenn posts and pages for one page?
- Custom Select Query pagination not working properly
- Display the latest post from some selected authors
- 404 for some custom taxonomy not ALL taxonomy
- Query Only Show Text on Posts With Certain Taxonomy Tag
- Make division in post_query?
- Displaying posts on Homepage
- Display one post randomly from category on home page
- Taxonomy Category category.php not working
- append $_GET parameters to post
- 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
- Change permalinks in posts via SQL