How to target the latest Post entry via <a href="" > (4 posts)

  1. nickmerr
    Posted 8 years ago #

    Hi there,

    I'm pretty new to WP and am trying to figure out the following:

    I've set by default homepage to be a static Page via the "Reading Settings"
    How do I then target the latest post entry via a <a href ?
    I've tried the <?php echo get_permalink(); ?> method but this just target the default page i.e. the static Page.
    I can target a specific post using the ID within the string such as:
    <?php echo get_permalink(1); ?> but this doesn't really solve the problem as I want the link to target the latest entry.

    Maybe I'm missing something quite obvious here but any direction would be much appreciated

    Thanks in advance

  2. moshu
    Posted 8 years ago #

  3. nickmerr
    Posted 8 years ago #

    Hey Moshu,

    Thanks for the link... Seems to be a common problem then.

    I used a snippet of your code to fix the problem

    <?php $temp_query = $wp_query; ?>
    <?php query_posts('showposts=1'); ?>
    <?php while (have_posts()) : the_post(); ?>

  4. " rel="bookmark" title="Permanent Link to <?php the_title(); ?>">Inspire
  5. <?php endwhile; ?>

    Thanks again !

  • moshu
    Posted 8 years ago #

    No, it is NOT a "problem" by itself. The problem always is that people want to do things that they don't have the skills for - so we write tutorials for them :)

  • Topic Closed

    This topic has been closed to new replies.

    About this Topic