Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Wordpress: create link to most recent post?

  • 05-11-2010 12:53pm
    #1
    Registered Users, Registered Users 2 Posts: 8,145 ✭✭✭


    Hi,
    I'm using Monotone theme, site is <a href="http://photoblog.ie">.
    I have a set homepage.
    In my navigation menu (in header) I want to add 'recent', which will link to the most recent post.

    At the moment I have to update the code each time I add a new post so +1 to the archive number-
    <li><a href="<?php bloginfo('url'); ?>/archives/1545/">recent</a></li>

    Thanks,
    Patrick.


Comments

  • Registered Users, Registered Users 2 Posts: 16,413 ✭✭✭✭Trojan


    This should work for you:
    <?php $my_query = new WP_Query('showposts=1'); ?>
    <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
    <li class="page_item"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endwhile; ?>
    

    (Can probably be optimised a bit more to remove while loop).

    HTH.


Advertisement