functionista
Member
Posted 2 years ago #
This is what code I'm using in the default theme's sidebar.php
<ul>
<?php
$myposts = get_posts('numberposts=6&category=1');
foreach($myposts as $post) :
?>
<li><?php the_date(); ?> <a href="<?php the_permalink(); ?>" title="<?php the_excerpt(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
<li> </li>
</ul>
and for some reason it only return the first listed post's date!? Please help!
the_date() is supporsed to displays the date only once for the first post on the same date.
You can use the_time() instead.
petitpoulain
Member
Posted 2 years ago #
i had the same problem. But its easy to solve. Just call the function setup_postdata just after you foreach.
Change to this
<ul>
<?php
$myposts = get_posts('numberposts=6&category=1');
foreach($myposts as $post) :
setup_postdata($post);
?>
<li><?php the_date(); ?> <a href="<?php the_permalink(); ?>" title="<?php the_excerpt(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
<li> </li>
</ul>
julienmarie
Member
Posted 2 years ago #
I experience exactly the same problem and i do not understand... my setup_postdata was there...but nothing appears
julienmarie
Member
Posted 2 years ago #
I experience exactly the same problem and i do not understand... my setup_postdata was there...but nothing appears