Assuming there is some function or variable that allows the shortcode access to its name, and for sake here I will term that $scName, is something like this possible:

function test_return_shortcode_name( $atts ) {
    return $scName;
add_shortcode( 'myName', 'test_return_shortcode_name' );

And so for this basic example, this shortcode:


Which would return the actual name as text


Does such functionality exist to access the designated name from within the function associated to it?


1 Answer 1


A shortcode can access its own name - it is supplied as third parameter to the shortcode's callback function, just like that:

function test_shortcode_callback( $atts = array(), $content = null, $tag ) {
    return $tag;
add_shortcode( 'test_shortcode', 'test_shortcode_callback' );

// So running this shortcode
// Will return this

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.