What I'm Trying To Do
I have set up a custom post type for 'movies' and below is how I set up the template. Basically, I am trying to get a.thickbox
(in the code below) to open a modal window with more info on the movie. Notice the addition of &pid=<?php echo $post->ID; ?>
at the end of the href
.
<?php get_header();?>
<section id="content">
<h2>Our Movies</h2>
<ul id="all-movies">
<?php
$c=0;
$i=1;
$temp = $wp_query;
$wp_query = null;
$wp_query = new WP_Query();
$wp_query->query('post_type=movies' . '&paged=' . $paged . '&posts_per_page=6');
while ( $wp_query->have_posts() ) : $wp_query->the_post(); $c++;
$custom = get_post_custom($post->ID);
$movie_info = $custom["movie_info"][0];
?>
<li id="movie-<?php the_ID(); ?>">
<?php if (!empty($movie_info)) { echo $movie_info ?>
<a class="thickbox" href="<?php bloginfo('url'); ?>/movies-modal?KeepThis=true&TB_iframe=true&height=820&width=610&pid=<?php echo $post->ID; ?>">View more info</a>
</li>
<?php
endwhile;
my_paginate_links();
$wp_query = null;
$wp_query = $temp;
wp_reset_query();
?>
</ul>
</section>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
My (Failed) Attempt
What I tried to do was create a separate template (below), create a page called "Movies Modal" in the dashboard, and attribute the template to the page. Then, I tried to grab the POST ID
from the a.thickbox
link from the template above (&pid=<?php echo $post->ID; ?>
) so only that post's info will show in the modal template below with this line: $wp_query->query( 'post_type=movies&p=' . $_GET['pid']);
<?php
/*
Template Name: Movies (Modal)
*/
?>
<?php get_header('thickbox'); ?>
<?php
$c=0;
$i=1;
$temp = $wp_query;
$wp_query = null;
$wp_query = new WP_Query();
$wp_query->query( 'post_type=movies&p=' . $_GET['pid']);
while ( $wp_query->have_posts() ) : $wp_query->the_post(); $c++;
$custom = get_post_custom($post->ID);
$movie_info = $custom["movie_info"][0];
$actor_bio = $custom["actor_bio"][0];
$actor_info = $custom["actor_info"][0];
?>
<div id="container">
<?php if (!empty($movie_info)) { echo $movie_info ?>
<?php if (!empty($actor_bio)) { echo $actor_bio ?>
<?php if (!empty($actor_info)) { echo $actor_info ?>
</div>
<?php
endwhile;
$wp_query = null;
$wp_query = $temp;
wp_reset_query();
?>
</body>
</html>
All this did, however, was bring up a modal window with the info for all posts and not just the info for the post the link is in, like this:
I can't figure out how to get the info for only the post I clicked on. Can someone please help me out or push me in the right direction?
Updates
pid is not set\ngettype: NULLpid intval: 0Array
(
[post] => post
[page] => page
[attachment] => attachment
[revision] => revision
[nav_menu_item] => nav_menu_item
[product] => product
[product_variation] => product_variation
[shop_order] => shop_order
[shop_coupon] => shop_coupon
[wpcf7_contact_form] => wpcf7_contact_form
[movies] => movies
[psdtv] => psdtv
)
Wordpress version: 3.5
Changed this block:
<li id="movie-<?php the_ID(); ?>">
<?php if (!empty($movie_info)) { echo '<span>Summary: '. $movie_info .'</span>'; } ?>
<a class="thickbox" href="<?php bloginfo('url'); ?>/movies-modal/?KeepThis=true&TB_iframe=true&height=820&width=610&pid=<?php the_ID(); ?>">View more info</a>
</li>