_tk_posted_on() - 整个日期而不是年份

时间:2016-05-19 11:40:23

标签: wordpress function datetime

我在ThemeKraft简单主题(Wordpress)中遇到了_tk_posted_on()函数的问题。 我会说,我会说,但我需要一些代码的帮助:

function _tk_posted_on() {
$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time>';
$time_string = sprintf( $time_string,
    esc_attr( get_the_date( 'c' ) ),
    esc_html( get_the_date() )
);

    $time_string = sprintf( '<a href="%1$s" title="%2$s" rel="bookmark">%3$s</a>',
        esc_url( get_permalink() ),
        esc_attr( get_the_time() ),
        $time_string
    );

    if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ){
        $time_string_update = '<time class="updated" datetime="%1$s">%2$s</time>';
        $time_string_update = sprintf( $time_string_update,
            esc_attr( get_the_modified_date( 'c' ) ),
            esc_html( get_the_modified_date() )
        );
        $time_string_update = sprintf( '<a href="%1$s" title="%2$s" rel="bookmark">%3$s</a>',
            esc_url( get_permalink() ),
            esc_attr( get_the_time() ),
            $time_string_update
        );
        $time_string .= __(', updated on ', '_tk') . $time_string_update;
    }

printf( __( '<span class="posted-on">Posted on %1$s</span>', '_tk' ),
    $time_string,
    sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>',
        esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
        esc_attr( sprintf( __( 'View all posts by %s', '_tk' ), get_the_author() ) ),
        esc_html( get_the_author() )
    )
);}

它发布整个日期和谁发布帖子,我希望它只发布年...我已经尝试编辑它..但我无法解决它.. 感谢您的帮助:)

1 个答案:

答案 0 :(得分:0)

    function _tk_posted_on() {
    $time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time>';
    $time_string = sprintf( $time_string,
        esc_attr( get_the_date( 'c' ) ),
        esc_html( get_the_date(Y) )
    );

    $time_string = sprintf( '<a href="%1$s" title="%2$s" rel="bookmark">%3$s</a>',
        esc_url( get_permalink() ),
        esc_attr( get_the_time() ),
        $time_string
    );

    printf( __( '<span class="posted-on">%1$s</span>', '_tk' ),
        $time_string,
        sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>',
            esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
            esc_attr( sprintf( __( 'View all posts by %s', '_tk' ), get_the_author() ) ),
            esc_html( get_the_author() )
        )
    );
}

你去,这个功能只显示年^^