Get custom post type slug for an archive page. 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:
1 2 3 4 5 6 7 8 | $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; } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.