iXiNX Club开放性测试进行中,欢迎体验反馈,如有任何问题均可联系管理员
iXiNX Club主要为自用型文档社区,同时也开放共用文档,欢迎爱好者加入并共享内容,翻译文档

自定义代码:在单篇文章页面中添加上次更新日期

版主: Code

回复
J
Jannah
二级成员
帖子: 154
注册时间: 2024年 3月 17日 07:42

自定义代码:在单篇文章页面中添加上次更新日期

帖子 Jannah »

1- 将此代码添加到您的子主题的functions.php文件中或通过允许添加自定义功能的插件(例如Code snippets插件)添加。避免将自定义代码直接添加到父主题的functions.php文件中,因为当您更新主题时,这些代码将被完全擦除。

代码: 全选

add_filter( 'TieLabs/post_date', 'tie_custom_code_post_date', 20 );
function tie_custom_code_post_date( $date ){

	if( is_single() ){
		return $date . '<span class="last-updated"> - '. esc_html__( 'Last Updated:', TIELABS_TEXTDOMAIN ) .' '. get_the_modified_date() .'</span>';
	}

	return $date;
}
2- 在Theme Options > Styling > Custom CSS > Custom CSS部分:

代码: 全选

.last-updated {
    display: none !important;
}

#the-post .last-updated {
    display: inline !important;
}
回复