WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This is an example of how I'm grabbing images from my custom post type now, using query_posts();

// query_posts stuff made up here.
$my_array = get_custom_field('image:to_array', 'to_image_array'); 
// $my_array is now all my images from that post.

What I want to do is pull out an image from a custom post type using get_adjacent_post(). When I print out the adjacent post's info, I don't see anything useful for pulling out my images from this post type. Here is a print_r of the adjacent post.

    [ID] => 185
    [post_author] => 1
    [post_date] => 2012-04-11 18:51:22
    [post_date_gmt] => 2012-04-11 18:51:22
    [post_content] => content
    [post_title] => the title
    [post_excerpt] => 
    [post_status] => publish
    [comment_status] => open
    [ping_status] => closed
    [post_password] => 
    [post_name] => the-title
    [to_ping] => 
    [pinged] => 
    [post_modified] => 2012-04-12 17:37:49
    [post_modified_gmt] => 2012-04-12 17:37:49
    [post_content_filtered] => 
    [post_parent] => 0
    [guid] => http://thewebsite.com/?post_type=photo_group&p=185
    [menu_order] => 0
    [post_type] => photo_group
    [post_mime_type] => 
    [comment_count] => 0

Is there a way to pull out my custom post type's images this way?

share|improve this question

get_custom_field is not a standard wordpress function, unless given the source code we cannot help you with it.

But I can tell you, that it is not getting its data from the post object, but the post meta.


$value = get_post_meta($post->ID,'key name',true); // where true indicates there is only a single key value pair of 'key name'
share|improve this answer

get_post_meta can help you as well. Use this way

global $wp_query;

$postid = $wp_query->post->ID;

echo get_post_meta($postid, 'key', true);
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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