• I’m trying to get a meta data field for an image. The variable is returning a string like this:

    a:2:{s:2:"id";s:3:"259";s:3:"url";s:77:"https://www.example.com/wp-content/uploads/sites/12/2014/11/image.jpg";}

    Is there a function I can use to access the URL from this structure?

    Thanks

Viewing 1 replies (of 1 total)
  • Are you using get_post_meta? If so, set the $single parameter to true. This will unserialize the array for you. Then you can do something like this:

    $meta = get_post_meta( $post_id, 'your_meta_key', true );
    $image_url = $meta['url'];
Viewing 1 replies (of 1 total)
  • The topic ‘Parsing meta data field’ is closed to new replies.