Use get_the_id() with an Array?
-
Hi Guys,
I’m working on trying to the list of id’s and have them put inside of an array. I’m currently using ‘get_the_id’ function inside a foreach loop. Then outside the loop, I’m trying to echo the largest id in the array. The issue I’m having is that the script returns the smallest id. My code is below, is there something I’m doing wrong?
-groq
<?php $posts = get_posts( "category=3&numberposts=100" ); ?> <?php if( $posts ) : ?> <?php foreach( $posts as $post ) : the_post(); ?> <? $latestpost = array(get_the_id()); ?> <?php endforeach; ?> <?php endif; ?> <? echo max($latestpost); ?>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘Use get_the_id() with an Array?’ is closed to new replies.