Digitalminds
Member
Posted 5 years ago #
The WordPress theme that I have installed is using the <?php get_archives('postbypost', 10); ?> to show the titles of the last 10 posts (included a link to the post) on the sidebar.
But I want to show the date & title of the last x posts on the homepage, like this:
date post | title post
I don't get it working with the get_archives function and couldn't find a solution on this forum, so could you please help me?
Use this:
<ul>
<?php
$latest = get_posts('numberposts=10');
foreach( $latest as $post ):
?>
<li><?php the_time(get_option('date_format')); ?> | <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach ?>
</ul>
References:
http://codex.wordpress.org/Template_Tags/get_posts
http://codex.wordpress.org/Template_Tags/the_time
http://codex.wordpress.org/Template_Tags/the_title
http://codex.wordpress.org/Template_Tags/the_permalink