I have a video viewing section on my site. The single post template displays a large area where the video plays and then there's a column of thumbnails representing other videos along the right side. Much like YouTube.
If the current video that is being displayed (let's say the post ID is 123) matches one of the thumbnail on the right (also ID 123) I want to give the thumbnail a different css class (represented by the inline style below) so I can highlight it, letting the user know this is the video currently playing.
I'm using wp_query to grab the posts for the right sidebar portion and I can't figure out how to compare the two IDs while in the loop. Below is a simplified version of what I thought would work, but it just gives the class to all iterations of the loop instead of just the current one.
<?php while ( have_posts() ) : the_post();
$primaryid = get_the_ID(); ?>
<?php
$args = array (
'post_type' => 'post',
'post_status' => 'publish',
'orderby' => 'meta_value_number',
'meta_key' => 'episode',
'order' => 'ASC',
);
// The Query
$query = new WP_Query( $args );
// The Loop
if ( $query->have_posts() ) { ?>
<?php while ( $query->have_posts() ) {
$query->the_post(); ?>
<?php if (get_the_ID() == $primaryid) {
$style = 'style="border: 1px solid #fff;"';
} ?>
<?php endwhile; // end of the loop. ?>