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 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

share|improve this question

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; ?>
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.