Forums

Date and Time of Most Recent Post (4 posts)

  1. mainecampus
    Member
    Posted 3 years ago #

    I was wondering if there's a quick tag that displays the date and time of the most recent post. Right now I'm using this:

    <?php if (have_posts()) :  while (have_posts()) : the_post(); ?>
    				<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_time('l, F jS, Y, g:i a') ?></a>
    			<?php endwhile; ?>
    		<?php else : ?>
    			<p class="center">Move along, nothing to see here.</p>
    		<?php endif; ?>

    But I need to be able to limit it to one post, and when I tried to do that it limited all the loops on the page to one post.

  2. MichaelH
    Volunteer
    Posted 3 years ago #

  3. mainecampus
    Member
    Posted 3 years ago #

    Well I was wondering if there was a tag that automatically added that information. This is what I have right now but it screws up my breadcrumb navigation:

    <?php global $post;
        $the_newest = get_posts('numberposts=1'); ?>
    
    				<?php foreach($the_newest as $post) :  setup_postdata($post);  ?>
    <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_time('F jS, g:i a') ?></a>
    <?php endforeach; ?>
  4. MichaelH
    Volunteer
    Posted 3 years ago #

    You will likely want to have a 'loop' that displays just that one post, then another that is your normal query loop.

Topic Closed

This topic has been closed to new replies.

About this Topic