WordPress:显示作者第一篇文章的日期

问题描述 投票:0回答:1

我正在寻找 PHP 代码来显示 作者第一篇文章的日期

我们想呼应作者页面上的日期。理想的是德国日期格式(例如 27.10.2023)

你有什么想法吗?

我找到了这段代码:

$user_id = 2;
$post = get_most_recent_post_of_user( $user_id );

if ( $post ) {
echo get_the_date( 'Y-m-d', $post );
}

但基本上我想要相反的。

不是最近的发布日期,而是当前作者的第一个发布日期。

wordpress date post author
1个回答
0
投票

尝试下面的代码:

$args = array(
    'post_type'     => 'post',
    'author' => $user_id
    'order' => 'ASC',
);
$posts = get_posts($args);

echo get_the_time('Y-m-d', $posts[0]->ID);
© www.soinside.com 2019 - 2024. All rights reserved.