Getting movie and serial on actor page

I’m building a cinema site, I came with a problem, let me explain:

  • Movies- are stored in Post’s
  • Actors- are stored in Post Type – persoane ( taxonomy= lista)
  • Serials – are stored in Post Type – serial ( taxonomy= seriale)

I use Advance Custom Field to link the Person to the movie –

enter image description here

AFC (http://www.advancedcustomfields.com/)

How i add:
I add new actor post to post type ( persoane), after i add the movie( in post’s), in sidebar(post’s, movie page) i link the actor (http://i49.tinypic.com/a8800.jpg).
After i Link the actor on the actor page it display the movie’s that actor play in

enter image description here

I use this code to do that

<?php 
//create new loop query for films by this actor
$movies = $wpdb->get_col("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = 'distributie' AND meta_value LIKE '%".get_the_ID()."%'");
$the_query = new WP_Query( array( 'post__in' => $movies) );

// The Loop
while ( $the_query->have_posts() ) : $the_query->the_post();
    echo '<div class="actor-box-related"><a class="actor-titlu" href="';
    the_permalink();
    echo '" title="'.get_the_title().'">';
    ?>
    <img class="actor-img" src="/scripts/timthumb.php?src=<?php the_field('img'); ?>&h=90&w=60&zc=1" alt="<?php the_title(); ?>"  title="<?php the_title(); ?>"/>

    <?php the_title();
    echo '</a></div>';
endwhile;

// Reset Post Data
wp_reset_postdata();
?>

The problem:

I create a Post Type – serial where I add the Serials (Ex: heroes,prisonbreak… )

How can i display on the actor’s page the serials that actor play in.
The custom_field for serials is “distributie_serial” – i change in that code but no sucess, it did not work.

The up code get me only the movies from post’s, how can i get the movies from that PostType (serial).

Can I put both together to get movies and serials? Or how can i display the serial’s on actor page, and IF no movie or serial is atach retrive the text “No movies for this actor”

Thanks in advance for those who help me.

Solutions Collecting From Web of "Getting movie and serial on actor page"

Hy,

i resolve a problem, a liitle question, how can i get the text if nothing is selected in custom field ( distributie_serial).
Ex: no serial for this actor.

This is the Code that works.

<?php 
$seriale = get_posts(array('post_type' => 'serial',
     'meta_query' => array(
                     array('key' => 'distributie_serial', // name of custom field
                           'value' => '"' . get_the_ID() . '"',
                           'compare' => 'LIKE'))
                        ));
?>
<?php if( $seriale ): ?>
<?php foreach( $seriale as $serial ): ?>
<div class="actor-box-related">
<a class="actor-titlu" href="<?php echo get_permalink( $serial->ID ); ?>">
<img class="actor-img" src="/scripts/timthumb.php?src=<?php echo get_field('imagine_serial', $serial->ID); ?>&h=90&w=60&zc=1" alt="<?php echo $photo['alt']; ?>" />
<?php echo get_the_title( $serial->ID ); ?>
</a>
</div>

<?php endforeach; ?>
<?php endif; ?>
<?php 
  $seriale = get_posts(array('post_type' => 'serial',
 'meta_query' => array(
                 array('key' => 'distributie_serial', // name of custom field
                       'value' => '"' . get_the_ID() . '"',
                       'compare' => 'LIKE'))
                    ));
?>
<?php if( $seriale ): ?>
<?php foreach( $seriale as $serial ): ?>
<div class="actor-box-related">
<a class="actor-titlu" href="<?php echo get_permalink( $serial->ID ); ?      >">
<img class="actor-img" src="/scripts/timthumb.php?src=<?php echo     get_field('imagine_serial', $serial->ID); ?>&h=90&w=60&zc=1" alt="<?php     echo $photo['alt']; ?>" />
<?php echo get_the_title( $serial->ID ); ?>
</a>
</div>

<?php endforeach; ?>
<?php else: 
echo 'Sorry! No serial for this actor.';
?>
<?php endif; ?>`