Get post info inside modal window?

It would appear your use of Thickbox is the culprit. When opening a thickbox via the anchor, the thickbox parameters must always be last, else the other parameters will be removed, e.g. your movies Post ID

http://devll.wordpress.com/2009/10/01/jquery-iframe-thickbox-removes-parameter/

Firstly, your use of queries is incorrect, what’s more you never tell your query which post to look for.

Instead you should do a proper query, e.g.:

$movie_query = new WP_Query( array(
    'post_type' => 'movies',
    'p' => $_GET['pid']
));
if($movie_query->have_posts()){
    while ( $movie_query->have_posts() ) {
        $movie_query->the_post();

    $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
    }
}
wp_reset_postdata();

Before you continue, you will need a grasp of how to do a basic query cleanly, and why and when to use it. For this I give you the following:

  • Never modify the main query directly. ( the only time to modify it is when it’s passed into a pre_get_posts filter )
  • Avoid query_posts
  • Read this quick presentation by Andrew Nacin, You don’t know Query, it will tell you what to use, how to use it, and why. It is considered by many necessary reading.

edit:

Please paste the following snippet above my modified version of your query:

echo '<pre>';
if(isset($_GET['pid'])){
    echo 'pid is set\n';
} else {
    echo 'pid is not set\n';
}
echo 'gettype: '. gettype($_GET['pid']);
echo 'pid intval: '.intval($_GET['pid']);
$post_types=get_post_types();
print_r($post_types);
echo 'Wordpress version: '.get_bloginfo('version');
echo '</pre>';

edit:

This code in your main listing is broken:

        <li id="movie-<?php the_ID(); ?>">
             <?php if (!empty($movie_info)) { echo $movie_info ?>
             <a class="thickbox" href="https://wordpress.stackexchange.com/questions/81475/<?php bloginfo("url'); ?>/movies-modal?KeepThis=true&TB_iframe=true&height=820&width=610&pid=<?php echo $post->ID; ?>">View more info</a>
        </li>

You never added a closing bracket for the if statement or a semi colon. I suggest you also replaced echo $post->ID; with the_ID(); and verify it is indeed printing the correct ID. I’d also suggest putting a “https://wordpress.stackexchange.com/” between the ?KeepThis and the movies-model

Leave a Comment