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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Wordpress: create link to most recent post?

  • 05-11-2010 11:53am
    #1
    Registered Users, Registered Users 2 Posts: 8,189 ✭✭✭


    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,414 ✭✭✭✭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