Force get_post_meta to Return an ID and not an Array for Image Fields

There are situations where you need to haveĀ get_post_meta return just the ID and not an array of Image ID’s from your image fields. The addition of pods_no_conflict_on(‘post-type’) will correct the behavior of this function call.

There are situations where you need to haveĀ get_post_meta return just the ID and not an array of Image ID’s from your image fields. The addition of pods_no_conflict_on(‘post-type’) will correct the behavior of this function call.

/*	To get an ID and not an Array() back for e.g image relations 
  	get_post_meta( get_the_ID(), 'single_product_image_bg', true ) 
	pods_no_conflict_on('post');
​*/

$image = get_the_image(
    array(
        'meta_key' => 'single_product_image_bg',
        'size' => 'full',
        'min_width' => 1100,
        'min_height' => 500,
        'order' => array('meta_key', 'default'),
        'link_to_post' => false,
        'before' => '<div class="product-image-large">',
        'after' => '</div>',
        'default' => '/wp-content/uploads/2015/11/genuss-standard-gelb-hintergrund.jpg',
        'echo' => true
    )
);
​
pods_no_conflict_on('post');

Questions