I am trying to create a shortcode in WordPress, in which the function that is called with the shortcode tag gets the shortcode tag as parameter.
So say I have
<?php
var $shortcode = 'my_shortcode_tag';
add_shortcode( $shortcode, 'my_shortcode_function');
?>
then I want 'my_shortcode_function'
to know the shortcode tag by it was called. I know that I could use attributes as in [my_shortcode_tag tag='my_shortcode_tag']
when I call the shortcode in my actual post, but I want to be able to just write [my_shortcode_tag]
and my function to know that it was called by that tag. Is there a way to do this?
This is sent in as the third argument to a shortcode function (as mentioned in the Shortcodes API).
for example:
this will output the name of the shortcode called for that function.