@EAMann’s answer is correct, but there’s already a build in WordPress function for fetching all registered post types: get_post_types
<?php
// hook into init late, so everything is registered
// you can also use get_post_types where ever. Any time after init is usually fine.
add_action( 'init', 'wpse34410_init', 0, 99 );
function wpse34410_init()
{
$types = get_post_types( [], 'objects' );
foreach ( $types as $type ) {
if ( isset( $type->rewrite->slug ) ) {
// you'll probably want to do something else.
echo $type->rewrite->slug;
}
}
}
Related Posts:
- Custom post type post_type_link gives “page not found” on any other custom post type
- Pulling in Related Posts based on Post Type array
- Rename a slug label
- Get an array wich contains the post_name of every post that has the custom post_type “pelicula”
- Add first letter of titles to array, then compare arrays
- Slug Confusion Between Post and Custom Post types?
- How to find a specific post_type using its “rewrite slug”?
- Different slug taxonomy for two different CPT
- Can I change my post type to anything and my site still work?
- Query Custom Post Types with checkboxes
- How to add current custom taxonomy slug to body class
- Change Slug of a Custom Post Type
- Using page slug in wp_query
- post_parent in custom post type
- Create Array from custom post type to display a slider
- How can Custom Post Type and a page have the same slug?
- Custom filter for main search: how to exclude specific post_type from search results
- How to get postname in custom page?
- Inefficient Query Confusion
- Querying multiple values from a single key
- Listing all slugs?
- get_post_types – exclude multiple post types by name
- Check if user has comment on current post
- Why WordPress is picking archive.php instead of page.php?
- Changing slug of all posts
- WordPress Custom Post Type – Rewrite Query
- WordPress different templates for same type custom post (but different slug)
- Remove taxonomies using register_post_type_args
- Custom post type and standard post not displaying or working
- post_type internal ID?
- Custom Post Type Advanced Slug
- get_terms() returns Trying to get property of non-object error for custom taxonomy
- Automatically update slug with latest title within custom post type [duplicate]
- Apply template by path/slug related to custom post type?
- Dynamic pages for linked categories and content
- Changing CPT slug and taxonomy already registered in parent theme
- Custom Post Type to replace Woocommerce products – page not found error
- How do I disply an array inside a custom post type?
- Custom Post Type for Shortcode Use – Prevent it display as a post (with slug)
- Custom post type in theme not appearing
- Custom Post Type Field Array parsing [closed]
- How to use a specific custom field in a custom post type as slug
- How to copy a custom field from the user’s CPT to the user’s normal posts
- Custom Post Types and Removing Slugs – should we do it?
- Getting custom post types to properly display alphabetically
- get_post_types not working properly in admin
- sort by name (slug) custom post type
- Need to return a string as permalink insted of str_replace
- How to controll the Posts post type and general wondering about WP data structure
- Under What Conditions Can I name my CPT the same as my CPT Page?
- Add filter to Admin list for all custom post types by their custom taxonomies
- Post Type => Any conundrum
- How can I loop at a Specific Taxonomy from a custom post type?
- Update value inside array update_post_meta
- How to change CPT single post slug
- How do I set a post slug automatically based on taxonomy?
- Custom archive page for custom taxonomy and pagination issue
- Custom post type and multi taxonomies + customize url
- How to hide list from custom post type
- Why is my custom post content only viewable when signed into WordPress?
- Custom Post type dont use custom page template (slug is not right)
- Custom rewrite rule based on other custom post type title
- Get an array of the number of post per year of a custom post type (WordPress)
- Use custom post type taxonomy between cpt slug and name
- Custom Post Type Single Page is not working
- Query when is one or several values
- Show code dependant on CPT & category
- Get all post types that supports tags
- Difference between a default post type and a custom post type?
- Remove custom taxonamy slug with pagination
- How can I write slugs / permalinks as: custom post type -> custom taxonomy and custom post type -> custom taxonomy (one CPT and many taxo)?
- custom post type single page not found after aotumatic publish By the author’s robot
- Custom Post Type not using correct page template
- Custom post type single with custom URL structure
- WordPress doesn’t respect Page slug in custom post type url pagination. Keeps getting removed
- Add %post_id% to slug of custom post type and prevent the “unique slug” thing that WP does?
- Staggering featured post using ‘sticky’
- Output all terms slugs for a loop filter
- Change permalink incrementor into pseudo-subdirectory
- add .html to custom post type with WPML
- How to mix 2 kinds of post types
- Custom post type URL structure with site.com/custom_taxonomy_slug/post_name
- Change Custom Post Type to Post + Category
- Custom Post Type duplicating slug for new posts
- If custom taxonomy exist on post?
- Shortcode in excerpt
- How can i order my posts by post type?
- Permanent Custom Post Type
- Two CPT: one is using part of the custom rewrite slug from the other
- WordPress page not showing up – replaced with last 10 posts?
- Custom permalink rewrite rules – how do I fix this?
- WP gives 404 error for custom post type with GET variable
- How to set a default CPT template and create post attribute´s display rules?
- Custom taxonomy archive slug overwrites static page
- Slugs on hierarchical taxonomies
- Post types showing tables…Can I do that?
- Convert Custom Post Data to Javascript Array for Autocomplete
- custom post permalink
- Display a Custom Post Type within another with hierarchically slug
- Problem to get the link of the default ‘post’ post type like the orther custom types