Try like this :
$args = array(
'post_type' => 'car',
'posts_per_page' => -1,
'tax_query' => array(
array(
'taxonomy' => 'your category/taxonomy name for post type car',
'terms' => 'term name/category name',
'field' => 'slug'
)
)
);
$query = new WP_Query($args);
$results = $query->get_posts();
print_r($results);
Yes every post has different slug, even if you have given same name.
For this you can create taxonomy term like which you have given post name, and assign this term to post you have in this category/term.
Ex.
Create taxonomy term named Post Slug
and assign it to both post and try my query with your respective parameters.
Related Posts:
- How do I query a custom post type with a custom taxonomy?
- Get the ID of the latest post
- Return all custom meta data for one custom post type
- Fail to compare dates in meta_query
- Custom post type archive 404’s with paginate_links
- Display Custom Post Type Fields
- Loading Custom Post Type Events into jQuery-based FullCalendar?
- Limit the post for differents custom post type in the same wp_query
- order by meta_value serialized array
- How to get the parent’s taxonomy?
- Loading post content in FancyBox
- Multiple templates for custom post type
- ascending order custom post type
- How to get only one category of custom post type?
- Used with meta_query in query_posts works slowly
- Query for posts in 2 taxonomies
- Prevent change with new query_posts()
- How to make an archive page displaying posts in a date range
- Custom Post Type sorted by Title
- How to display recent posts added in several custom post types
- Display custom post types with custom date field value (before today) & order by custom date field
- How to dynamically build a multiple taxonomy query loop within a post type’s single loop?
- List custom post type by custom tax term as page title
- Custom query shows custom post types in trash
- Multiple post type queries (with specific arguments for each)
- What’s a better alternative to this code?
- Archive for custom taxonomy lists all posts instead of current taxonomy
- How to query_post custom posts within default taxonomy?
- child of post type (custom)
- How to use custom taxonomies to reference complex relationships?
- Order query using custom meta data
- Query Custom posts of same taxonomy as the post itself
- Get latest 3 posts from multiple CPT in one query
- Conditional Query of Custom Post Type and custom taxonomy
- will post_id ever change? Can I safely use post_id for custom queries?
- Show a Category X’s custom post type on Category X archive page?
- Custom Post Type Query for Sidebar Doesn’t Work on Front Page
- How to edit this code to get the categories in achieve page?
- Category with post type pagination returns 404
- Homepage’s content is dependent on the custom field values (set automatically), how do I get homepage to update without manually updating page?
- Query posts based on the meta key values of logged-in users?
- Different Ways to Query Custom Post Types?
- Listing all term items alphabetically / sorting loop
- query_posts adding extra code to homepage
- How to show only the most recent post on my custom post type archive?
- How to make WP_Query not to show irrelevant posts?
- What is the ID parameter for custom post types in query_posts?
- Loop for custom post types filtered by a taxonomy
- Why are some of my custom posts not showing up on my page?
- post-per-page and offset not working
- Custom post type, custom taxonomy, query posts only from taxonomy (children of)
- Getting all ID’s matching a title in a custom post type
- Querying multiple values from a single key
- find custom post type post by searching its custom field with my string
- FacetWP paging custom wp_query
- Can’t change posts per page in WordPress Post Type Query
- Incorrect ordering of custom post type based on time
- List all posts in taxonomy term
- Query all post types but limit to parents
- Query Multiple Custom Post Types & Exclude a Taxonomy Term
- Query Custom Post Type based on text input
- Custom Post Type Query W/Category Dropdown
- Query all posts under one taxonomy? Why is my code not working?
- Custom Post Types Not Showing Up In query_posts Result
- Find Posts based on Child Post value
- Custom Post Type ‘Event’: Chronological list of recurring events from meta_values in array
- Showing only posts from the current user who is logged in?
- returning the currect URL for nested posts
- Sticky posts limit query and pagination for a custom post type
- Custom post type archive page filters
- Create a post automatically if search result has zero results
- Limit custom post type to the authors only on front-end!
- Posts per Page on custom Taxonomy Template
- Use WP_query to match post types based on custom field values
- minimize wp_query call to database
- Group Custom Posts Types in a Relation field of ACF
- Use WP pagination functions on a custom page template
- Can I show some specific post rather than latest post?
- Getting Custom Posts with Custom Taxonomy
- How do I get the posts from single page custom post type from a sidebar to display in a page?
- How to set class to “current-page” on the currently viewed single post within a CPT
- WordPress custom post type
- Display 2nd category, only once, as sub-heading, in the loop
- WordPress custom post type queries
- query_post causes the posts to be loaded twice on load more posts
- Query Distinct Taxonomies of Custom Post Type
- Custom Query With Multiple Meta Key Value
- Ordering custom post type by custom field without a title
- How can I list custom post by custom category?
- Query Posts From Multiple Post Types
- Return only custom post types for the page, not all
- Advanced Custom Fields: query posts filtered by multiple field values
- WP Build-In Post selector for CPT
- How to apply order on custom taxonomy and custom meta key on custom post type
- Inserting two categories
- How to exclude certain portfolios from a loop
- Render a loop in Timber (twig for WordPress)
- show custom post’s post in two different divs [duplicate]
- How to get Custom post type by related category ID
- Quering array of post types & pagination. Articles are repeating sometimes on different pages