Save variable from The_Loop??!
-
This is the_Loop that i’m using to display some post links:
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<li><a href="<?php echo get_permalink() ?>"><?php echo $post->post_title; ?></a></li>
<?php endwhile; ?>
<?php else : ?>
<?php endif; ?>I would like to save the_ID of the first post in the loop in a variable that I could use later.
Something like
<?php $myVar = the_ID(); ?>
But I can’t put that within the loop because firstly, it will print on the page, secondly it will be overwritten in every “loop” and thirdly, it seems to be emptied at the end of the loop.
What can i do? Please, any help will be hugely appreciated!
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Save variable from The_Loop??!’ is closed to new replies.