Last active
November 15, 2017 08:35
-
-
Save yuriitaran/84aee2faf3b514458f2656f16d659987 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Show post type Singular Label on singular post page: | |
$post = get_queried_object(); | |
$postType = get_post_type_object(get_post_type($post)); | |
if ($postType) { | |
echo esc_html($postType->labels->singular_name); | |
} | |
// Show post type Singular Label in the loop: | |
$postType = get_post_type_object(get_post_type()); | |
if ($postType) { | |
echo esc_html($postType->labels->singular_name); | |
} | |
// Show post type Singular Label above the top of 'while': | |
$postType = get_post_type_object( 'photogallery' ); | |
// >> These two usually contain the post type name in plural. | |
// >> They may differ though. | |
echo $postType->label; | |
echo $postType->labels->name; | |
// >> This one holds the post type name in singular. | |
echo $postType->labels->singular_name; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment