Are you trying to display the current post’s title dynamically in some way? or perhaps inside its own post content? Or somewhere else?
Not quite sure on the usecase here, which would help me provide a better answer.
I created a post-type Movie and I have published some posts on it now I want to show the Custom post type title (i mean I want to show the word “movies”) in the posts of Movie only.
I am waiting for your reply,
Thanks.
Something like this should work
add_shortcode( 'post_type_title', 'nick1999_post_type_title' );
function nick1999_post_type_title( $atts ) {
$atts = shortcode_atts( [
'post_type' => '',
], $atts );
if ( empty( $atts['post_type'] ) ) {
return '';
}
$obj = get_post_type_object( $atts['post_type'] );
return $obj->label;
}
Usage example: [post_type_title post_type="movies"]
Would return: Movies if the plural label is as such. Editing the plural label later would affect all of the instances of the shortcode.
Hi,
Thanks for your support,
my issue has been solved,
you can mark this thread as resolved,
Thank you, Sir.
Glad we could help. Let us know if anything else comes up.