The shortcode’s name is referred to as the tag. The tag is actually the 3rd (and last) parameter passed to the shortcode’s callback function.
So your callback should look something like this:
function print_shortcode($atts, $content, $tag) {
// $atts - array of attributes passed from shortcode
// $content - content between shortcodes that have enclosing tags eg: [tag]content[/tag]
// $tag - shortcode name
// do something... perhaps:
switch($tag) {
case 'dog':
// some code
break;
case 'cat':
// some code
break;
case 'asparagus':
// some code
break;
} // switch
}
Related Posts:
- Using get_option() in JavaScript
- Shortcode empty attribute
- Using wp_editor in shortcode
- Shortcode in shortcode: How to append variable?
- How can i put an array as variable in shortcode_atts?
- Table of Contents with a shortcode
- Using action hooks inside of a shortcode
- Using shortcodes in PHP
- Remove width and height attributes from [gallery] output
- Is it possible not to define category on function.php and add the shortcode [shortcode cat=1] to display the products?
- Add_shortcode as a Class to pass arguments to a function
- Prevent add_shortcode from escaping a tag
- Shortcodes not working in an AJAX call
- Remove HTML content if attribute is not set / variable attributes
- Legacy Audio Shortcode
- Extending the Audio Shortcode
- How resource intensive is wp_register_script()?
- Convert shortcode into html form [closed]
- Numbering Image List in Gallery
- How to enable shortcodes in text retrieved from get_theme_mod
- Register visits of my pages in wordpresss
- Is it possible to ignore the first Line Break in a preformatted Div from a shortcode?
- List monthy archives for specific year with wp_get_archives
- How can I included CSS to a page or a shortcode? [closed]
- Two Shortcodes in one page not working
- Call Shortcode inside another Shortcodes callback
- Creating a shortcode in a plugin that includes JS
- Shortcode to delete post from front end
- MathJax inside shortcode
- How to parse shortcodes within returned content
- Hook WP_Embed run_shortcode
- Shortcodes attributes defaults
- Get Required Assets (JS, CSS etc) for post using REST API
- shortcode in snippet plugin not work
- AJAX and Shortcode with Parameters
- Detecting embeded video format
- While loop shortcode problem
- How to prevent shortcode preview from breaking in tinymce editor?
- Execute Closing Shortcode After the_content
- How to protect parts of my code from TinyMCE modification when switching from text to visual mode?
- Responsive Embeds using default embed shortcode
- Shortcode output appearing at the top of the page only [duplicate]
- problem with shortcodes nesting
- OOP and WordPress shortcode
- PHP/WordPress — How do I check if Shortcode returns content?
- Convert my php code into shortcode
- Custom shortcode breaks my page
- Add shortcode with open close function
- Shortcode is not working
- Custom shortcode is causing a WSOD
- Why can’t I display attachment_image_src with Custom Size?
- Get attributes of nested shortcodes
- Enclosing Shortcode is acting like self-closing
- Shortcode into the same shortcode
- How to create a shortcode to let the user add the ID of a YouTube video?
- Execute shortcodes in PHP
- A shortcode nested inside a shortcode
- How to add shortcode to html widget
- Custom Shortcode + Querying and Ordering Posts using multiple Advanced Custom checkboxes
- Add div on EMED Tag
- call other shortcode in the email contactform7 send [closed]
- Putting a space between the buttons [closed]
- Processing a login/register form before shortcodes are rendered?
- Adding a cover image to video shortcode
- Insert First Image into post (full-width)
- Dynamic number within shortcode
- How can i strip shortcode from HTML title tag?
- Returning HTML to Shortcode Block
- WP REST API remove the WordPress shortcodes from the JSON wp/v2/posts content->rendered
- How to display html element and php string in the same line?
- Hide download option video shortcode
- WordPress Shorcode Display hierarchical taxonomy [child, parent]
- Shortcode not working in Jetpack Top Posts & Pages widget
- Restricting shortcode for users
- Gutenberg running code only available in front end within shortcode
- Insert HTML in content property and render it using shortcodes
- Redirect per shortcode if user is logged in
- Shortcode, vs blocks, vs templates – what would you do for choosing or creating custom post data in editor?
- create shortcode that changes url endpoint
- Convert WordPress shortcodes into plain html
- Attributes are not passed on nested shortcode
- How to make a shortcode with a line break in it parse correctly?
- Removing text + shortcode from all posts
- Plugin Shortcode value in post
- Woocommerce Filter Main Loop by Tag [closed]
- Shortcodes: override a shortcode / change shortcode on the fly
- Access the resized images generated by `add_image_size()`
- Separating Custom Template logic
- Defining the output of a WordPress Att
- Custom WP theme not showing shortcodes
- Shortcode for sectors
- woocommerce Product shortcode create [closed]
- A number appears inside a div called wpb_wrapper, when I use a custom shortcode
- Enclose article’s body with default shortcode
- Why is my ajax live search not working when i use a shortcode to call it?
- Shortcode with foreach
- My first WordPress shortcode just returning []
- WordPress shortcode select option not working [closed]
- I have the query code but not the shortcode
- wordpress how to sort posts on custom data with plug-in “Search & Filter”