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

I have register bellow custom post type in function.php and I am using Advanced Custom Fields. Using advance custom field type I have added one image field and assigned to my Release custom post type.

Now I have added one post inside Release post type. I have fill this details in this post.

Title: Speak Now (Deluxe Edition)
Image: Added some Image

Now I want to retrieve meta data with specific post by title/id.

I have tried this code but not working:

$my_post_meta = get_post_meta(556, 'album_image', true);
    if ( ! empty ( $my_post_meta ) ) {

My custom post type:

 * Music/Releases
function codex_custom_init5() {
  $labels = array(
    'name'               => 'Releases',
    'singular_name'      => 'Release',
    'add_new'            => 'Add New',
    'add_new_item'       => 'Add New Release',
    'edit_item'          => 'Edit Release',
    'new_item'           => 'New Release',
    'all_items'          => 'All Releases',
    'view_item'          => 'View Release',
    'search_items'       => 'Search Releases',
    'not_found'          => 'No release found',
    'not_found_in_trash' => 'No release found in Trash',
    'parent_item_colon'  => '',
    'menu_name'          => 'Release'

  $args = array(
    'labels'             => $labels,
    'public'             => true,
    'publicly_queryable' => true,
    'show_ui'            => true,
    'show_in_menu'       => true,
    'query_var'          => true,
    'rewrite'            => array( 'slug' => 'release' ),
    'capability_type'    => 'post',
    'has_archive'        => true,
    'hierarchical'       => false,
    'menu_position'      => null,
    'supports'           => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' )

  register_post_type( 'release', $args );
add_action( 'init', 'codex_custom_init5' );

My Post Type

share|improve this question
up vote 2 down vote accepted

get_field is a replacement for get_post_meta you have to use only it:

$my_post_meta = get_field('album_image', 556);

if ( ! empty($my_post_meta) ) {
   // use the image

If you don't know the ID and want retrieve the post meta via post name, you have to use WP_Query or get_posts to ge the post via slug:

$posts = get_posts('post_name=here-the-post-name&post_type=release');
$mypost = ( ! empty($posts) ) ? array_pop($posts) : false;
$my_post_meta = $mypost ? get_field('album_image', $mypost->ID) : '';
if ( ! empty($my_post_meta) ) {
  // use the image
share|improve this answer
Thank you so much for your help :) – Rajnikanth Oct 15 '13 at 6:23

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.