Hi,
In one of my theme I use multiple loops using new WP_Query.
Example: my content contains a classic loop calling a page or a post and my sidebar contains two custom loops calling one specific page or post.
/* sidebar loops */
<?php $customLoop1 = new WP_Query('page_id=5');?>
<?php while ($customLoop1->have_posts()) : $customLoop1->the_post() ;?>
<!-- content stuff here -->
<?php endwhile; ?>
<?php $customLoop2 = new WP_Query('page_id=10');?>
<?php while ($customLoop2->have_posts()) : $customLoop2->the_post() ;?>
<!-- content stuff here -->
<?php endwhile; ?>
The problem now: if I put this code below these loops:
<?php echo $post->ID; ?>
It returns me the ID of each post/page calling by the custom loop and not the ID of the current post. And I think it's normal.
But, how to retrieve the current post ID outside of the classic loop?
Any help would be greatly appreciated!