• I’m trying to do something really fun, really clever, and if I get it to work, it will totally kick some serious butt…

    But it all hinges on my shortcode function being able to get the name of the shortcode tag that was matched. I’ve looked at the documentation. It says the third parameter is the tag name. I’ve looked at the code. It really LOOKS like it should be passing back the shortcode as the third parameter.

    But no matter how hard I try, I can not get the matched shortcode name. It’s not in $attr[0]. It’s not in $content. It’s not in the third parameter.

    Can anyone actually get the shortcode name in the third parameter in 3.2.1?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter jarrowwx

    (@jarrowwx)

    Nevermind, it is in $attr[0] – here’s where I went wrong:

    function shortcode_template( $attr = null, $content = null, $shortcode = null ) {
    ...
      if ( ! isset( $shortcode ) ) {

    It should have been

    if ( empty( $shortcode ) ) {

    Silly me. Why did I think isset() would return false?

    I also can’t get $attr[0] to echo… how did you solve this?
    I just want the name of the used shortcode in a variable, that’s all.

    Thread Starter jarrowwx

    (@jarrowwx)

    Post your code that you are using. Then also, post the way you are using the shortcode. That is, are you using it with content, or not, with attributes, or not, and is the shortcode name the same as your function name, or not. Lay it all out so we can look at what you did.

    I fixed this issue last night, but I am not sure if it is the correct way, see this topic: here

    The reason is: I am checking if $content is null, and then I use $shortcode… seems stupid, but it is the only way that I got it working…

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Third parameter to shortcode callback is never populated’ is closed to new replies.