Forums

Displaying Latest Blog Title/Link (2 posts)

  1. prig
    Member
    Posted 3 years ago #

    Hey,

    Currently when my users arrive to my site, they are greeted with a default static page that introduces my non-profit company. There are different sub sections as well.

    Currently, there is an area that mentions the latest blog title and a link to that post. I'm assuming instead of manually editing this page, there is some sort of code I could use to automatically pull this information each time and update the page without me having to do so.

    How could I get this to work? I know it would be similar to the widget that displays X amount of posts, but haven't figured out what file that code is stored in yet. If someone could point me in the right direction, that would be great.

    Thanks!

  2. lhoylhoy
    Member
    Posted 3 years ago #

    <?php $latest = new WP_Query(); $latest->query('showposts=1'); while($latest->have_posts()) : $latest->the_post(); $wp_query->in_the_loop = true; $latest_ID = $post->ID; ?>

    insert that above your <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a> (put above <div> if it has one)

    you can see the ('showposts=1'), there you can set how many latest posts you want to display

Topic Closed

This topic has been closed to new replies.

About this Topic