Get all custom post types:
$post_types = get_post_types( array ( '_builtin' => FALSE ), 'objects' );
Sort them by their name:
uasort( $post_types, 'sort_cpts_by_label' );
/**
* Sort post types by their display label.
*
* @param object $cpt1
* @param object $cpt2
* @return int
*/
function sort_cpts_by_label( $cpt1, $cpt2 ) {
return strcasecmp(
$cpt1->labels->name,
$cpt2->labels->name
);
}
Link the post type names to their archives if archives are actually available:
foreach ( $post_types as $post_type => $properties ) {
if ( $properties->has_archive ) {
printf(
'<a href="https://wordpress.stackexchange.com/questions/175365/%1$s">%2$s</a><br>',
get_post_type_archive_link( $post_type ),
$properties->labels->name
);
}
}
Related Posts:
- Custom Post Type Archives by Year & Month?
- Get custom post type slug for an archive page
- Custom Post Type Settings page, choose page to display archive
- Adding a menu item for a Custom Post Archive
- Adding custom post type archives to a WordPress menu
- Custom Post Type Template – Archive
- How do you create an archive for a custom post type from a plugin?
- Custom Post Type Archives by Date with Custom Permalink
- Change title in head on Archive page
- What are the advantages of using a custom post type archive?
- Page is defaulting to archive page and not designated template
- custom post type archive page url to point to Page permalink
- Better to use a post type archive, page template, or shortcode for generating a highly configurable CPT archive?
- Add Settings to Custom Post Type
- Custom Post Type Works but Still Shows “Page Not Found”
- Rewrite custom post type url’s adding meta box values
- I can’t set meta_key in my custom post type query
- Adding Sticky functionality to Custom Post Type Archives
- Archive page for taxonomy of custom post type
- Add meta data to the custom post type ARCHIVES page
- archive-{$post_type}.php not loading. instead the default archive.php loads
- Create Custom Post Type Archive Page with Sub Categories Navigation Sidebar
- Custom query variable – get wordpress to redirect to nice permalink url
- add_rewrite_endpoint() and Custom Post Type Archive
- Custom post type archive page pagination
- Add custom post type archives to search results?
- Archive page for custom post type not working
- Editable content on a Custom Archive page
- Second Custom Post Type Archive
- An empty Custom Post Type Archive page returns 404 in WP 3.1
- is_main_query() not working for WP REST API
- WP_Query | ‘post_type’ doesn’t work
- Editable Meta Data for Custom Post Type Archive Template
- Archives for Custom Post Types (without Pages)
- Set up Custom-Post-Type Author Archive
- get the custom post type title/name
- Custom post type templating problem
- Displaying Page as Custom Post type landing Page
- Single post with a Custom Post Type returns 404, when archives of the CPT work correctly
- CPT archive admin menu label
- Custom post type archive page blank
- Creating a Custom Post Type
- Custom Post Type slug same as page name
- Content Editable CPT Archive?
- Paginate_links in custom post type template
- Limit the Title Length on Custom Post Type Archive Page to a Set Number of Characters
- How to hyperlink content from archive page with custom post-type
- How to set up Custom Post Type archive page as Front page
- Custom Permalinks For CPT and pages with parent. Advanced WordPress
- How to integrate single and archive templates for custom post type in any WordPress theme
- ACF for custom post type archive pages: which hook to use?
- CPT Archive pre_get_posts not working?
- Removed custom post type archive page shows blog page
- Custom Post Type with Configurable Sidebar via ACF
- Plain links in single-class.php and archive-class.php not working
- Make Next and Previous on single-$posttype.php use the same order as archive-$posttype.php
- CPT archive page – show one post from each taxonomy term
- Create a Custom Path to Archive
- Specifying a template for custom post type pages
- How to set a ‘page’ as parent of a custom post type?
- Archive page of CPT’s custom Taxonomy
- 2 Custom Post Types In 1 Archive Page?
- Custom post type archive URLs with a single taxonomy
- Different number posts per page based on custom post type term id
- How to change URL for custom post type archive?
- Displaying all posts by category and showing content on click
- Custom post type author issues
- ACF Pro Accessing fields on a Custom Post Type
- Do not show child pages within a file page
- Tell wordpress to show a single page instead of an archive page
- Custom taxonomy with custom post type archive page
- Custom post pagination not working
- Custom post type post_type_link gives “page not found” on any other custom post type
- Custome post type “tags” pick default archive instead of custom post type archive
- Highlight a Post on archive page if it has a new comment?
- Custom Post Type shows pagination (w/404) or posts_per_page query, but not both
- How do I make my archive page look like popular reviewing sites (e.g., Polygon and Gamespot) [closed]
- Rewriting archive page slug to be different than custom post type slug
- Site loads very slow for archive custom post type page
- Remove the “View” Link in Post edit Admin
- Custom Post Type Archive Links Not Working
- CPT archive as home page
- Have two (permalinks) urls for a same custom post type
- Archive page of filtered posts
- How to display the FAQ Archive page in my menu
- Why is this custom post type defaulting to archive.php?
- How can I set up the URL for a category archive for a custom post type?
- Taxonomy Query of Custom Post Displays Archive Instead of Posts
- Archive Page Pagination not working
- single-mySlug.php works: archive-mySlug.php does not. Custom Post Type
- Create a Page Templete to Display Table Of Content for Custom Taxonomies
- has_archive for default post type
- Pagination for Custom Post Type with Multiple Types
- Custom Post Type Archive Title Lowercase
- Custom Post Types using wrong template (index) instead of archive-{type}.php – previously worked as expected
- Show custom post type on post category page doesn’t work / breaks navigation
- On archive.php show loop for child categories if they exist or posts if they don’t, on custom post type
- Pagination not working on custom post type archive
- Best practice to display a list/archive of Custom Posts in a Page Template
- Archive pagination – second page shows exactly the same posts