我有WordPress主题,我正在使用get_the_date
函数来获取帖子的发布日期:
<?php echo get_the_date( 'M-d-y' ); ?>
但是似乎使用get_option( 'date_format' ).
会更好。
如何使用get_option
函数显示发布后的日期?
发布于 2017-07-13 01:52:16
不需要使用get_option
来获取发布日期。您可以通过正确使用get_the_date
函数来实现此功能。
以下是的解决方案:
$post_date = get_the_date( 'l F j,Y‘);echo $post_date;
$post_date = get_the_date( 'D M j‘);echo $post_date;
在wordpress文档中阅读更多关于get_the_date和检查date formatting选项的信息。
https://stackoverflow.com/questions/45064048
复制相似问题