Wordpress 申请日期在列表中每一天的最后 post 之后

Wordpress apply date after last post of each day in list

你能帮我在每天的最后 post 申请 '<span> this is last post of <date> </span>' 之类的东西吗?这是一个包含对象的数组:

    Array
    (
        [0] => WP_Post Object
            (
                [ID] => 845
                [post_author] => 3
                [post_date] => 2015-02-18 15:01:37
                [post_date_gmt] => 2015-02-18 13:01:37
                [post_status] => publish
                [post_content_filtered] =>
                [post_type] => post
                [post_mime_type] => 
                [comment_count] => 0
                [filter] => raw
...
            )...

如有任何帮助,我们将不胜感激。

这很奇怪,但我会做的是有点诡计,你不关闭当前 post 容器直到下一个 post 的循环,然后你可以比较当前 post 与下一个约会,然后继续。尝试这样的事情...

<?php 

if ( have_posts() )  :

    //Set a variable before the loop so we can test if its the first post
    $first = true;

    //Define 2 variables, one to store current date, one for next date
    $current_day = $next_day = null;

    //Start the loop
    while ( have_posts() ) : the_post(); 

        //Set next date
        $next_day = get_the_date( 'd-m-Y' );

        //End the container of the last post on every post except the first
        if( !$first ) {

            //If the current post has a different day to the last include a message
            if( $current_day != $next_day ) {

                echo '<span>This is the last post of ' . get_the_date( 'd-m-Y' ) . '</span>';

            }

            //Close the container of the last post
            echo '<div>';

        }

        //From now on the post is not the first
        $first = false;

        //Now we can set current date
        $current_day = $next_day;

    ?>

        <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

            <!-- include the contents of your post here but don't close the container! -->

    <?php endwhile; ?>

    <!-- close the container of the last post -->
    </div>

<?php endif; ?>

希望对您有所帮助

此致