To get the current post type use get_post_type()
. Then ask get_post_type_object()
for all the data you need, for example the slug:
$post_type = get_post_type();
if ( $post_type )
{
$post_type_data = get_post_type_object( $post_type );
$post_type_slug = $post_type_data->rewrite['slug'];
echo $post_type_slug;
}
Related Posts:
- Custom Post Type Archives by Year & Month?
- Meta_Query as a way how to setup CPT permalinks – is it a good thing?
- Proper way of making custom post type landing page or archive page
- Custom Post Type Archives by Date with Custom Permalink
- Change title in head on Archive page
- Custom Post Type Archives with 0 Posts Redirects as 404
- Page is defaulting to archive page and not designated template
- Better to use a post type archive, page template, or shortcode for generating a highly configurable CPT archive?
- paginate function in archive for custom-post-type
- Custom post type archive sorted and grouped by date in post meta field
- How to create archive page for taxonomy terms within custom post type
- WordPress custom post type archive with description
- Custom-post-type-archive: posts sorted/filtered by year?
- How to list custom post types?
- Custom post type archive page pagination
- Editable content on a Custom Archive page
- Second Custom Post Type Archive
- is_main_query() not working for WP REST API
- CPT Archive with core Category
- Changing number of posts per page on CPT-archive.php, have tried 20-30 code chunks so far
- get the custom post type title/name
- URL of a custom post type’s post format archive?
- Create template for taxonomy results limited by Custom Post Type
- Custom post type archive page blank
- How to display custom post in archive section of the wordpress page?
- What’s the name of the custom post type yearly archive template?
- How can I use archive-{post_type}.php theme template?
- Return the name of the post type
- Use the custom post type archive for taxonomies?
- Archive page for custom post type and custom taxonomy
- How to have multiple archive pages?
- Create a Custom Path to Archive
- Custom Post Type Date Based Archive URL rewrite [duplicate]
- WordPress sitemap with Custom Post Types
- Is possible register two archive pages for single custom post type?
- Custom Post type page content (archive page)
- Group custom post type posts by month
- Creating an archive page or simple template to list all values of a custom field of specific post type listing
- Do not show child pages within a file page
- Tell wordpress to show a single page instead of an archive page
- Custom Post Type archive page listing a 404 or single post
- Want to display my custom date archive to date.php but dont know how
- Rewriting archive page slug to be different than custom post type slug
- Site loads very slow for archive custom post type page
- Stop Custom post type from being searched via URL
- Custom post type category page not working
- paging is not working properly on news archives page [duplicate]
- 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
- Pagination not working for archive
- How to have a dynamic slug and rendering the archive-{post_type}.php?
- Remove plugin’s custom post type archive page and single pages [closed]
- WordPress CPT archive page display sticky post first and then display the rest of the posts in same Query
- How to remove custom post type archive
- How to use a custom post type archive as front page?
- How to set a custom post type to have viewable future posts
- Custom post type pagination 404 fix?
- How to filter custom post type archive by meta value
- Custom Post Type / Taxonomy Slug / Post Title with post type archive
- Should I change these content meta types before building complex archive page?
- Category and post tag archives do not include posts from custom post type
- Display CPT description on archive.php pages for all CPT
- Display only post types that are direct children of the current taxonomy
- How can I give CPT archive correct body class?
- Custom Post Type Archive Page Filtering
- Custom post type is showing custom home page, not archive page
- How to use has_archive but disable feed per post type?
- Custom post type: Disable single page, but keep archive
- Custom Post Type has_archive
- list archives per post types
- Display a custom posts page for post type
- Is it possible to have a custom post type with feed but without the archive?
- Is it better to use filter for the_content in archive pages?
- My archive-posttype.php template is not loading
- Add parent post to Custom Post Type [closed]
- Archive not sorting correctly
- multiple custom post type on category page
- How to display CPT archives?
- current-menu-item not added on page showing custom post type (rendered with archive template)
- Custom taxonomy or custom page templates?
- Permalink problems with custom post type and custom taxonomy
- How do I add custom HTML to the content of an archive page’s posts?
- Only show posts with a specific term of an associated taxonomy in a custom post type archive
- How can I tell if I’m on a custom post type archive page?
- CPT archive with WP native/core tax/categories
- How to add specific terms in a custom post type?
- WordPress Page hierarchy ( parent is singular of custom post types slug ) is returning not found
- Custom WordPress theme not displaying posts from category
- Order archive custom posts by taxonomy term [duplicate]
- How to manage a custom post type archive as a page?
- Custom post types not displaying per category
- Custom post type with two templates
- Custom Post Type tag taxonomy “Page Not Found”
- Custom Post type archives / categories give 404
- Archive.php is not displaying tags
- CPT Archive with parent page
- Categories in custom post types
- How to turn custom-post archive into an overview page, listing the metadata of the posts?
- custom post type not getting archived?
- Show custom category archive as front page and remove taxonomy slug from urls