如何在wordpress帖子中只显示月份和年份

How to only show month and year in wordpress post

本文关键字:显示 wordpress      更新时间:2023-09-26

我不知道如何在wordpress帖子的输入日期中只显示月份和年份
有什么建议吗?这似乎不是wordpress控制面板的标准配置。

您可以在此处设置日期格式:Admin>Settings>General>Date Format

但是,您的主题可能未使用此设置。在这种情况下,你必须编辑你的主题并使用

<?php the_time(get_option('date_format')); ?>

在每个显示发布/页面日期的文件中。

  • https://wordpress.stackexchange.com/questions/591/how-to-get-the-date-format-and-time-format-settings-for-use-in-my-template

请参阅http://php.net/manual/en/function.date.php

使用

<?php date('Y-m', strtotime($your_time_variable)); ?>