Wordpress - 为entry_meta函数添加帖子标题

时间:2016-10-11 07:33:13

标签: php wordpress

我想将帖子标题添加到模板tags.php文件中的TwentySixteen Wordpress主题中的entry_meta()函数中。我想在作者信息之前打印。但是在头像之后。

基本上就在“屏幕阅读器 - 文本”范围之前。

功能部分:

if ( 'post' === get_post_type() ) {
    $author_avatar_size = apply_filters( 'twentysixteen_author_avatar_size', 205 );
    printf( '<span class="byline"><span class="author vcard">%1$s<span class="screen-reader-text">%2$s </span> <a class="url fn n" href="%3$s">%4$s</a></span></span>',
        get_avatar( get_the_author_meta( 'user_email' ), $author_avatar_size ),
        _x( 'Author', 'Used before post author name.', 'twentysixteen' ),
        esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
        get_the_author()
    );
}

在printf中添加the_title()并不起作用。所以不确定如何处理这个问题。

感谢所有愿意提供帮助的人。

1 个答案:

答案 0 :(得分:0)

想出来。

添加了get_the_title()并使用%5 $ s

调用它
if ( 'post' === get_post_type() ) {
    $author_avatar_size = apply_filters( 'twentysixteen_author_avatar_size', 205 );
    printf( '<span class="byline"><span class="author vcard">%1$s<h1 class="entry-title">%5$s</h1><span class="screen-reader-text">%2$s </span> <a class="url fn n" href="%3$s">%4$s</a></span></span>',
        get_avatar( get_the_author_meta( 'user_email' ), $author_avatar_size ),
        _x( 'Author', 'Used before post author name.', 'twentysixteen' ),
        esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
        get_the_author(),
        get_the_title()
    );
}