Last active
September 21, 2023 13:29
-
-
Save dantetesta/33f73b2dd5f245a19e0796fda6ee20d9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
function cpt_posttype_name_shortcode($atts) { | |
// Atributos padrão | |
$a = shortcode_atts(array( | |
'cpt' => 'post', // 'post' é o valor padrão caso nenhum slug seja fornecido | |
), $atts); | |
$post_type_object = get_post_type_object($a['cpt']); | |
if ($post_type_object) { | |
return esc_html($post_type_object->labels->name); | |
} else { | |
return 'Post Type não encontrado'; | |
} | |
} | |
add_shortcode('cpt_posttype_name', 'cpt_posttype_name_shortcode'); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment