Variable : Get_queried_object_id in the repeater
-
Hello,
Hello,
I try to display an Ajax Load more sidebar post list on single.php and Iwould like to add a specific class to the item currently queried on single.php. So I get the ID of the ajax loaded item into $thisPostID and compare it with $thePostID that should retrieve the queried page ID.I tried with :
global $wp_query;
$thePostID = $wp_query->post->ID;
And
$thePostID = get_queried_object_id();Both work fine in my template files but not in the Repeater template.
Any idea how to work this around? Thanks by advance for your help.
Below is a snippet of my repeater, with the If/ELse statement to set the css classes
<?php $thisPostID = get_the_ID(); // Ajax loaded item ID, works fine global $wp_query; $thePostID = $wp_query->get_queried_object_id(); ?> <article id="post-<?php the_ID(); ?>" <?php if ($thePostID == $thisPostID ) { post_class("c-news-list_item current_c-news-list_item"); } else { post_class("c-news-list_item"); } ?>> // content </article>
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Variable : Get_queried_object_id in the repeater’ is closed to new replies.