• Hello,
    I have one array. like this :

    $test[‘1′,’2′,’3’];

    and now I want to create shortcode that will return me that array. And that array i get outside of shortcode function.

    $test[‘1′,’2′,’3’];

    var_dump($arrt);
    function movies_func($arrt) {
    return ‘test’;
    }
    add_shortcode(‘movies’, ‘movies_func’);

    I need to push that array in shortcode fucntion and then return it, and show on page, with shortcode. Is there any way to do that? And i don’t want to create my array in that function.

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    Shortcodes only handle string data, not arrays or objects. You could serialize and unserialize the array before and after the shortcode to make it into a string, but this would only be feasible with shortcodes invoked with do_shortcode(). It will not work in normal content since you cannot have PHP code in content.

Viewing 1 replies (of 1 total)

The topic ‘Array in shortcode function’ is closed to new replies.