Wordpress - Custom field array of image ID's

admin

Administrator
Staff member
I'm using the new wordpress custom post types and fields.

It's all working great, but for a custom image field (where I can select multiple images in one field), the value of this field when output is an array:

Code:
<?php
$field = get_post_meta($post->ID, "puma", false);
echo $field[0];
?>

This results in the following output (there are 3 images here):

Code:
180|177|174

These are clearly the image ID's stored in the wp_posts table of the database.

However, before I go mad trying to do this manually via an SQL query (hack), I was wondering if there is a better and more native way in wordpress to get the value of these or the proper way to output these images?

Cheers,
Michael.

EDIT:

Thanks to some help I got below, the final code for anybody who needs it is this:

Code:
<?php

    $field = get_post_meta($post->ID, "myImageField", false);
    $str = $field[0] . "|"; // add an extra pipe at the end to get ALL the items (kinda tricking it.
    $theIDarray = explode('|', $str, -1);

    foreach ($theIDarray as $value) {

        echo wp_get_attachment_image($value, "myCustomImageSize");

    }

?>

This works for a custom field with multiple image selections for the 'content-types-wordpress-plugin'. Hope it helps those in need!