$index = 'A';
$terms = get_terms('manufacturer');
foreach ($terms as $term) {
if($index != strtoupper(substr($term->name, 0, 1))) {
$index = strtoupper(substr($term->name, 0, 1));
echo '<h1>'. $index . '</h1>';
}
?>
<h2><?php echo $term->name; ?></h2>
<?php $args = array( 'post_type' => 'cars', 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC',
'tax_query' => array(
array(
'taxonomy' => 'manufacturer',
'field' => 'slug',
'terms' => array($term->slug)
)
)
);
// ============================= OUTPUT ==============================
$loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post();
the_title('<h3>', '</h3>');
the_content();
endwhile;
}
Related Posts:
- How to sort list of custom posts to get view like a tree of posts under categories and their children’s categories?
- How to change permalink structure for custom post type and it’s taxonomies?
- Get the first post term
- Creating “static” taxonomies to choose from, inside custom post type?
- How can I list all the categories under a Custom Post Type (taxonomy)?
- How to list all categories and tags in a page?
- How can you make permalink work for custom post type and taxonomy?
- How to get a list of term names of the custom post type im currently on in single.php
- List all custom post type posts from a given category?
- Custom post type taxonomy template
- Display Posts of a Category in Alphabetical Order (Custom Post Type)
- get_categories for custom post type and filter by custom taxonomy (brand) and list child categories of a defined category
- Category page only displaying the posts from a custom type
- Show Post Count of a Category
- Custom Post Types and Categories?
- How to create new category for custom post type?
- Get Post Primary Category
- Pagination is not working on single-{slug}.php but works fine on page-{slug}.php
- How to get the post type from a category id?
- How to show CPTs in term archive
- Display all posts in main category and 1 subcategory
- Show category ID on custom post type
- Categories of custom taxonomy don’t show any posts
- How to display custom taxonomies with links in filter menu?
- Limit amount of posts made within a custom taxonomy
- Conditional statement for if archive page has posts which contain certain taxonomies/categories/tags, show those terms
- How do you create a custom template to display a category with an image and related posts below?
- Custom Post Type Category Link
- Custom Post type category pages template and loop
- Categories and tags for custom post types
- get_category_link() for custom post type does not include custom slug rewrite?
- Targeting categories in custom fields
- Invalid Taxonomy
- Need help deciding on a taxonomy
- Get Posts by Category, Tag , and CPT Taxonomy
- Get assigned post categories
- Default Category Page not showing custom post type which has taxonomy category
- How to get the current category with custom posts
- Categories won’t appear on custom post type
- Custom Post Type with modified permalink structure results in 404
- Custom post type, taxonomy and admin bar
- Displaying taxonomies as category links within sidebar and creating pages for these
- Using get_terms() to list terms from one custom taxonomy AND from one specific built-in category
- Display ONE taxonomy and its assigned pages
- Custom post type archive page filters
- How to show related posts of category on post within custom posttype
- get taxonomies from terms
- Create custom post type categories
- Set a Default CPT taxonomy by taxonomy id
- how to create custom taxonomy drop downs for parents and child
- How to manage a dynamic multi-level page hierearchy system?
- Categories manage
- I can not call the categories of custom post type
- Reuse the “category” slug for a custom post type
- How to create groups like that in buddypress?
- Update Cateogory Taxonomy Count for Attachment Post Type
- Best way to structure article and issue relationship for CPT
- Custom Post Type used for FAQs Accordion
- category_name not working in WP_Query
- How can I set up the URL for a category archive for a custom post type?
- show only one category posts in admin
- Is it possible for post and custom post type to share a category base slug?
- Category display using conditions
- Separate archive template to show posts and CPT by same category/taxonomy
- Add taxonomy or category slug to custom post types URL
- How to determ a custom post type url?
- “Menu order” being ignored when querying posts from a parent taxonomy with “include_children” set to true
- Problem with custom loop navigation inside the blog page
- WordPress giving me the index
- Can I use the ‘category’ taxonomy for both posts and a custom post type?
- How to get post count of specific taxonomy that have store name & category
- Menu for taxonomies and posts belongs to taxonomy
- How to automatically create a terms based on each post of a post type
- Multiple categories assigned to a single product breaking the breadcrumb
- Get List of Terms based on a given term (different taxonomy)
- CPT archive with WP native/core tax/categories
- Duplicate slug/permalink issue while adding same post name
- Page that lists publications by classifying them by taxonomy
- How to use pre_get_posts on archive page custom post type
- How to divide Subcategories into pages of parent category wordpress
- Question about link two types of data in wordpress
- Add Tags to a Custom Post Type from a FrontEnd Form
- Can I automatically assign a page template to a custom post type (i.e page-slug.php file)
- CPT : Next or Previous term link when has not adjacent post
- Display all Categories except ones with a specific parent
- Custom post category name showing empty
- Display custom post types by category
- What is the best way to set the post category (Custom Post Type) automatically based on the one of the tags assigned to the post?
- Custom front-end form for adding post – Category problem
- Do post types share the same records using the same taxonomy?
- How To Display Posts Of Custom Post Type At Page Template
- Order posts by taxonomy terms
- Virtual page and loading template
- Custom Post type dont use custom page template (slug is not right)
- Get the taxonomy value in the post loop inside the archive page
- How best to structure multiple CPTs and tax within a ‘resources’ section
- Custom post type archive URLs with a single taxonomy
- How to change Elementor Template for Single Page Post on Load
- Filter taxonomy by CPT
- automatically select taxonomy based on post meta