Mandarke
Member
Posted 3 years ago #
Hello, this seems like an awfully obvious question, but I've looked through the documents and can't find an answer, so please forgive me if I've missed something.
I've got a 'static' front page and wish to have a link to the latest blog entry. What would this url look like, is there a code I could use in the header.php to create the link?
Many many thanks!
Something like this would probably work. This code should be entered in a template page or sidebar page, not in the Page editor.
It will grab the most recent post across all categories. You can exclude some categories too but this code doesn't address that.
<?php
global $post;
$myposts = get_posts('numberposts=1');
foreach($myposts as $post) :
?>
<p><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></p>
<?php endforeach; ?>