I have made a shortcode [get_clients] which is supposed to return an array of all the clients when called via do_shortcode('[get_clients]'). But all it returns is a string 'Array' only. Why?
1 Answer
This function returns a string. So you should join the elements of the array to make a string.
From the Codex:
Function Reference/do shortcode
Return Values
(string)
Content with shortcodes replaced by the output from the shortcode's handler(s).
-
1I can serialize an array before returning and then unserialize it.arxoft– arxoft2014-02-17 11:44:53 +00:00Commented Feb 17, 2014 at 11:44
-
Please read @G. M.'s comment as well: "Shortcodes are intended to be used to print something on the screen."rocknrollcanneverdie– rocknrollcanneverdie2014-02-17 11:54:31 +00:00Commented Feb 17, 2014 at 11:54
do_shortcode()returns only string values.