• Resolved eonlova

    (@eonlova)


    Have problem to show posts date.
    Some of them will show up but not all of them. can not see any pattern for this, seems more like it is totaly random.
    Here is some code that I use:

    <?php
    query_posts('cat=4&orderby=date&posts_per_page=3');
    if (have_posts()) :
    while (have_posts()) : the_post();
    $do_not_duplicate[] = $post->ID
    ?>
    
    <div class="newsPost">
    <a title="<? the_title(); ?>" href="<?php the_permalink(); ?>">
    <? the_title(); ?><br />
    <? the_date('Y M d'); ?>
    </a>
    </div> <!-- Closes newsPost -->
    
    <?php
    endwhile;
    else : ?>
    
    <div class="post">
    <h2 class="center">Sidan kan inte hittas</h2>
    <p class="center">Sidan som du letar efter har flyttats eller finns inte.</p>
    </div> <!-- Closes Post -->
    
    <?php
    endif;
    wp_reset_query();
    ?>
    </div>
    
    <div class="press">
    <h3>Middagsfrid i media</h3>
    <?php
    rewind_posts();
    query_posts('cat=6,8&orderby=date&posts_per_page=3');
    if (have_posts()) :
    while (have_posts()) : the_post();
    if (in_array($post->ID, $do_not_duplicate)) continue; update_post_caches($posts);
    $Source = get_post_meta($post->ID, 'Source', $single = true);
    ?>
    
    <div class="newsPost">
    <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
    <?php the_title(); ?><?php if ($Source != '') echo ", ".$Source ?>
    <br /><? the_date('Y M d'); ?>
    </a>
    </div> <!-- Closes newsPost -->
    
    <?php
    endwhile;
    else : ?>
    
    <div class="post">
    <h2 class="center">Sidan kan inte hittas</h2>
    <p class="center">Sidan som du letar efter har flyttats eller finns inte.</p>
    </div> <!-- Closes Post -->
    
    <?php
    endif;
    wp_reset_query();
    ?>

    This hav been a problem for a long time and I would be pleased if there is anyone who can help me with this.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Michael

    (@alchymyth)

    http://codex.wordpress.org/Template_Tags/the_date

    SPECIAL NOTE: When there are multiple posts on a page published under the SAME DAY, the_date() only displays the date for the first post (that is, the first instance of the_date()). To repeat the date for posts published under the same day, you should use the Template Tag the_time() with a date-specific format string.

    MichaelH

    (@michaelh)

    Instead of using

    <? the_date('Y M d'); ?>

    use

    <? the_time('Y M d'); ?>

    oops beaten to the punch…

    Thread Starter eonlova

    (@eonlova)

    Thanks for a fast reply, this solved the problem.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Postdate won’t show up’ is closed to new replies.