0

Im trying to get titles from IDs in string, but I'm getting stucked when I want to use get_the_title() function and receving error

implode(): Invalid arguments passed

$act_name = explode(',', $unserialized['_gravity_form_lead']['9']);
$titles = implode(', ', get_the_title($act_name)); 

where $unserialized['_gravity_form_lead']['9'] returns string like 3115,3116

any ideas?

  • get_the_title accepts a single post ID and returns a string. you are trying to pass an array, and using the result as if it is an array. – Milo Dec 28 '16 at 17:36
0

get_the_title takes an int, not an array of ints, and therefore returns a string, not an array of strings.

So just break that bit out into a loop:

$titles = '';
foreach ($act_name as $act_name_item) {
  $titles .= ($titles ? ',' : '') . get_the_title ($act_name_item);
}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.