get_the_date();显示wordpress安装的日期,而不是发布日期


get_the_date(); displays the date of wordpress installation, not post

我在wordpress中显示每个帖子的日期时遇到问题。对于每一篇帖子,它都显示安装日期,而不是发布日期(每一篇文章都在不同的日子发布,但现在都显示相同的日期,这似乎是随机的)。尝试将get_the_date();在没有运气的情况下,每一次失误。有人知道为什么吗?

$postsnumber = $nm_theme_options['numberposts']; 
        $args = array( 'numberposts' => "$postsnumber" );
        $recent_posts = wp_get_recent_posts( $args );
        $date = get_the_date(); 
        foreach( $recent_posts as $recent ){                 
            echo '<li><a href="' . get_permalink($recent["ID"]) . '">' .  $date .' '. $recent["post_title"].'</a> </li> ';
    }

找到了我的问题的解决方案!

<?php
        $postsnumber = $nm_theme_options['numberposts']; 
        $args = array( 'numberposts' => "$postsnumber" );
        $recent_posts = wp_get_recent_posts( $args );
        foreach( $recent_posts as $recent ){    
            echo '<li><a href="' . get_permalink($recent["ID"]) . '">' .  date('d.m.y', strtotime($recent['post_date'])) .' '. $recent["post_title"].'</a> </li> ';
    }
    ?>

很抱歉在这方面做得很新,但谢谢你的帮助!