• Resolved gbambury

    (@gbambury)


    Hello All

    I created a shortcode snippet (like below), how do I pass an argument $list_name to the function when calling it via the shortcode.

    [test_list_copy]

    — code snippet—
    add_shortcode( ‘test_list_copy’, function ($list_name) {
    my code here
    }

    Kind Regards Guy

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Shea Bunge

    (@bungeshea)

    You can add parameters to the shortcode like this:

    [test_list_copy something="42" another="Hello"]

    And then access them in the shortcode fucnction like this:

    add_shortcode( 'test_list_copy', function ( $list_name ) {
        return $list_name['something'] . ' ' . $list_name['another'];
    } );
    Thread Starter gbambury

    (@gbambury)

    That’s nice and simple.

    I got that working.

    Thank you.

    Plugin Author Shea Bunge

    (@bungeshea)

    Good to hear!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Passing a ‘function argument’ through the shortcode’ is closed to new replies.