【发布时间】:2018-10-05 22:34:09
【问题描述】:
我对 PHP 很陌生。我想显示上次更新日期而不是发布时间。有人能帮我吗?非常感谢。
if ( ! function_exists( 'minimalistblogger_posted_on' ) ) :
function minimalistblogger_posted_on() {
$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';
}
$time_string = sprintf( $time_string,
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date() ),
esc_attr( get_the_modified_date( 'c' ) ),
esc_html( get_the_modified_date() )
);
$posted_on = sprintf(
esc_html_x( 'Posted on %s', 'post date', 'minimalistblogger' ),
'<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>'
);
$byline = sprintf(
esc_html_x( 'by %s', 'post author', 'minimalistblogger' ),
'<span class="author vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . esc_html( get_the_author() ) . '</a></span>'
);
echo '<span class="posted-on">' . $posted_on . '</span><span class="byline"> ' . $byline . '</span>'; // WPCS: XSS OK.
}
endif;
【问题讨论】:
-
你这里用什么框架?
-
$timestring可能会显示更新的日期,但在设置后从未使用过。 -
它在 Wordpress 上。但在帖子上,它只显示“发布于……发布日期……”
标签: php wordpress date datetime