Can you try to escape the variable $post_id?
Like so: ”.$post_id.”
So use the single quote twice.
You are querying a slug and your variable is a number.
Related Posts:
- Why is my WP_Query not working when tax_query terms are an array?
- How to get any tag ID
- WP Query for Posts (Products) in Specific Category that has 2 Specific Tags (*AND* both tags not *OR*)
- How to add terms to my tax_query based off of the current post
- Pass array of taxonomy terms to wp_query
- Formulate a url to show posts with both taxonomy terms
- Taxonomy search/filter with multiple taxonomies and multiple taxonomy terms
- Order by slug in get_terms with multiple taxonomies
- WordPress Related Post by tags in Single.php
- Function get_queried_object() return NULL in custom taxonomy
- Return Taxonomy/Term Information with Posts (WP_Query/get_posts)
- Get authors by term id or slug
- Taxonomy order exception for specific term
- Get posts from multiple tax terms
- How to Order a list of taxonomies? orderby?
- How to add custom meta to ‘pre_get_terms’?
- get term id from term name
- WP Job Manager plugin – Listing only the twelve job categories on frontpage order by jobs they have
- Can’t get term id for category archive
- How to make a post with certain taxonomy term display first before other post with only one query?
- How can I order a post query’s results based on the number of matching taxonomy terms?
- Save queried result into database
- taxquery taxonomy get terms
- How to show terms from another taxonomy
- How to define a custom hierarchy for terms?
- How can I get taxonomy term name using term slug & post ID using build in WordPress function or class?
- Control term order on a per-post basis
- WP query taxonomy input differs to output?
- Exclude posts that only have the ‘Uncategorized’ category [duplicate]
- post_type is ignored by WP_Query when ‘tag’ argument is included
- Get All IDs Of A Post Type Using WP_Query
- Order posts by tags count?
- Move posts to top of WP_Query if in certain Taxonomy?
- Adding a term name from a custom taxonomy assigned to a post link displayed by a wp_query loop based on another taxonomy
- Querying Multiple Custom Taxonomy Terms
- Get random terms
- Order terms inside a select dropdown
- WP Query – Get WooCommerce Products with variation that is in stock
- Filter WordPress posts by between parameter
- How to Modify Taxonomy Archive Page with Search Parameter?
- Get array of current post term ID’s
- Pagination problem after WP_Query with tag filtering
- Change default ordering of taxonomy terms – pre_get_terms
- Display link to taxonomy archive only if it has posts with certain custom field values
- Is it possible to dynamically get queried term AND taxonomy?
- WP Query for variable taxonomies
- Get list of terms that have posts in another term
- Why does querying on post_tags (which has been applied to custom post types) only return posts?
- Getting Taxonomy inside WP_Query Loop
- Complex WP_Query (two post types and multiple operators)
- Search for multiple tags?
- Remove category from query (show all posts in archive.php) pre_get_posts()
- Display Featured Post by Categories and Avoid duplicated posts
- Cluster WooCommerce products in each Category Archive by Tags assigned to products
- WP_Query tax query part of slug
- How to Union two different conditions in one WP_Query
- Query posts intersecting tags and categories
- How do I exclude the lowest level terms in a taxonomy?
- Search Query for multiple categories using ‘OR’ but having certain categories be ‘AND’
- WordPress query with items from more than one selfdefined taxonomy as `term` argument
- Post loop for all taxonomy terms
- Is There a Difference Between Taxonomies and Categories?
- Order by most used tag
- WP Query with multiple tags by get the tags
- Getting the post terms ‘wp_get_post_terms’ per post when within the functions.php file
- How to print term name inside wp post loop
- Loop posts based on permalink term
- Using WP_Query for categories instead of get_terms
- Check if a post has term inside loop
- Grabbing taxonomy terms and inserting them into an array
- How to get posts by category and by choosing a taxonomy term?
- Don’t repeat posts from children in parent taxonomy query
- Determine if ID is page or post and query the ID
- Show multiple tax_query from 2 or more post_type in a single code
- Deleting terms from the WordPress wp terms table
- get_the_terms has strange result since version 6.0
- Filter products on category AND tag
- Strange behaviour of hierarchical taxonomy archive
- WP Query should show No Posts when tax_query $args taxonomies don’t have associated posts
- tax_query not working on custom post type
- WooCommerce WP_Query using tax_query returns no results (0 = 1)
- Get posts that match defined arrays of tags
- WordPress – Form does not filter the results of taxonomies
- Order posts by tags count?
- Show one post of each custom taxonomy
- getting posts by tags
- How to break up output of posts for different terms on same page?
- Custom category page with taxonomy filters
- Show posts from categories instead of tags
- Custom taxonomy and query multi conditions
- Random posts in WP_Query when searching by tag
- Empty ‘terms’ in ‘tax_query’ returns an empty array
- How to get several fields from wp_query?
- Issue with WP_Query (need a array of selected ID’s)
- GET Taxonomy ID
- Displaying Results From Custom Taxonomy Query
- Limit Tags display and ad Drop Down Menu
- Multiple Orderby is not working right
- taxonomy-{term}.php terms pagination returning 404 after a certain page
- Using WP Query, I want to include all posts in category 1 as long as they are not also in category 2