I have two custom post types called actors and movies. In movies, I have a custom meta box that got data from actors post type.

When an actor is selected in movie post, the values (post_id, meta_key and meta_values) are stored in postmeta table.

So I build a page to show all movie info. Fot that, I'm using WP_Query:

        $args_movie = array('post_type' => 'movie','posts_per_page' => -1);
        $movie_posts = new WP_Query($args_movie);

        if($movie_posts->have_posts()) : 
           while($movie_posts->have_posts()) : 

        <h2><?php the_title() ?></h2>

     <?php endwhile; else: ?>
        Oops, there are no posts.
     <?php endif; ?>

This works fine for me. Now I'm trying to show all actors associated with each movie. This script return an array of IDs:

$actors= get_post_meta( get_the_ID(), 'actors'); print_r($actors); 

But how can I using this array to get actor's titles?


$args = array('post_type' => 'actors','orderby' => 'ASC','post__in' => $areas);

more info

1 Answer 1


You can make use of ids in $actor the following way to get the actor's title.

$args = array(
    'post_type' => 'actors',
    'post__in'  => $actors,

$actors_posts = new WP_Query( $args );

if( $actors_posts->have_posts() ) :
    while( $actors_posts->have_posts() ) : 
        <h2><?php the_title() ?></h2>
    <?php endwhile; else: ?>
        echo 'Oops, there are no posts.';
<?php endif; ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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