感谢观看。我正在使用一个独白插件插件在幻灯片标题中显示帖子日期。我想将发布日期更改为人类差异或“小时前”格式。我正在转换get_the_date
在函数文件中使用以下内容
// Relative date & time
function wpse_relative_date() {
return human_time_diff( get_the_time(\'U\'), current_time( \'timestamp\' ) ) . \' ago\';
}
add_filter( \'get_the_date\', \'wpse_relative_date\' );
插件是
function sol_soliloquy_fc_date_terms( $content, $post, $data ) {
// Start Config
$sliderSlugs = array(
\'your-slider-slug-name\',
);
// Check slider ID is the one we want to amend
if ( ! in_array( $data[\'config\'][\'slug\'], $sliderSlugs ) ) {
return $content;
}
// Build date and taxonomy terms content
$additional_content =
\'<div class="soliloquy-fc-date">\'
. __( \'\', \'soliloquy-featured-content-date-terms\' ) . get_the_date( \'dS F Y\', $post->ID ) . \'
</div>\';
// Return content
return $content . $additional_content;
}
add_filter( \'soliloquy_fc_caption\', \'sol_soliloquy_fc_date_terms\', 1, 3 );
这会输出第一篇帖子创建的天数,其他所有帖子都是一样的,所以我猜它不会每次都返回帖子,因为它在循环之外。我是一名php新手,我猜这与不能使用
$post->ID
内部
get_the_date
.
非常感谢您的帮助!