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 -
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:
After I link the actor on the actor page it display the movie's that actor play in
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.
add_image_size
andthe_post_thumbnail
instead. Also your 'distributie' post meta should be a custom taxonomy called 'distributie'.$movies = $wpdb->get_col("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = 'distributie' AND meta_value LIKE '%".get_the_ID()."%'");
var_dump($movies);
gives you? An array?