Adding ‘current_post_item’ class to current post in the loop

You should be able to get the queried object id and use that for comparison inside your custom loop..

Before your existing loop code(what you have posted above), but obviously after the opening PHP tag..

global $wp_query;
$current_id = $wp_query->get_queried_object_id();

Then somewhere inside your custom WP loops..

if( $current_id == get_the_ID() ) {
    // This result is the current one
}
else {
    // Not current
}

Hope that helps..

Leave a Comment