我在下划线后失去了Author_Name

时间:2018-12-14 18:19:03

标签: php wordpress web

我正在与我的wordpress杂志网站设计合作。我正在设置帖子,标题下方需要“作者姓名|最后更新日期” 。使用$post_author = get_the_author();,我得到了想要的东西,但是Author Name只是一个简单的文本,而不是Author的个人资料链接。因此,我尝试了$post_author = the_author_posts_link();。有了这个,我得到了Author_Name的依据|最后更新的修改日期” ,而不是得到“由Author_Name |的最新更新日期” 。下面是我放在wordpress主题的function.php中的代码,然后是输出。请帮我修复。预先感谢!

我在function.php中编写的代码:

if ( $author == 'no' && $date == 'no' ) {
    return;
}

$post_author = the_author_posts_link();
// add compatibility when used in header before loop
if ( empty( $post_author ) ) {
    global $post;
    $post_author = get_the_author_meta( 'display_name', $post->post_author );
}
$u_modified_time = get_the_modified_time(‘U’);
$post_date = date_i18n( get_option( 'date_format' ), strtotime( get_the_date('r') ) ); 
$u_time = get_the_time('U'); 
$u_modified_time = get_the_modified_time('U'); 
$updated_date = get_the_modified_time('F jS, Y');

echo '<div class="post-byline">';
if ($u_modified_time >= $u_time + 120) {
// translators: %1$s = the author who published the post. %2$s = the date it was modified
printf( esc_html_x( 'By %1$s | Last Updated on %3$s', 'This blog post was published by some author on some date ', 'mission-news' ), esc_html( $post_author ), esc_html( $post_date ), esc_html( $updated_date )) ;}
    echo '</div>'; 
}

以及我得到的:

<div class="post-byline">
<a href="localhost/root/author" title="Posts by author" rel="author">Author</a>
By  | Last Updated on December 13th, 2018
</div>

0 个答案:

没有答案