WordPress.org

Forums

Inconsistent Code (4 posts)

  1. nicolethompson11
    Member
    Posted 6 years ago #

    Hi Again,

    I cannot figure out why the date is only showing on the first (most recent) post in my "Latest Posts" list at the foot of the page:

    http://www.rayah.org/rhemagarden/

    Here's the code

    <div class="left">
    
    		<h2>Latest Posts</h2>
    
    		<ul class="block">
    
    <?php
    $myposts = get_posts('numberposts=5');
    
    if ($myposts) :
    
    	foreach ($myposts as $post) :
    
    		setup_postdata($post);
    
    		unset($categories);
    
    		foreach (get_the_category() as $category)
    			$categories[] = $category->cat_name;?>
    
    <li><a href="<?php the_permalink();?>">
    <span><?php the_title(); ?></span>
    <em><?php the_date();?></em></a></li>
    <?php endforeach;?>
    <?php else : ?>
    				<li>no entries</li>
    <?php endif;?>
    			</ul>
    
    		</div>

    Any help appreciated :)
    Nicole

  2. whooami
    Member
    Posted 6 years ago #

    probably because you are using the_date .. Might want to read that.

  3. nicolethompson11
    Member
    Posted 6 years ago #

    OK.... sorry, but that doesn't help me much, what exactly is wrong with my code? how can I fix it?

  4. adam-s
    Member
    Posted 6 years ago #

    Try...

    <?php the_time('F j, Y'); ?>

    instead. whooami's link says it all in each of the first 3 sentences. All will become clear to those who follow the link.

    The above should display something like May 5, 2008.

Topic Closed

This topic has been closed to new replies.

About this Topic