• Resolved Ryan Stutzman

    (@ryan-stutzman)


    In a function with a form that grabs a string, the following code prints an array containing the comma-separated data in that string:

    $locations_string = esc_html( get_post_meta( $item_id, 'locations', true ) );
    $locations_array = explode(',', $locations_string);
    $locations_array_trimmed = array_map('trim', $locations_array);
    Print_r($locations_array_trimmed);

    and the variable ‘locations’ is saved to the database.

    However, the code prints an empty array in a function further down the page. Any ideas why this might be?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘get_post_meta Returns an Empty Array inside a Function’ is closed to new replies.