我的WordPress博客正在运行一个自定义主题,它将每个词条的日期显示为相同的日期:今天。我在我的主页上显示了最后三篇文章,但这些日期很好。然而,我的博客主页显示了每一篇文章的当前日期。
我可以FTP到我的网站,并可以访问所有的PHP文件,问题是我不知道这个错误可能在哪个文件中,无论是index.PHP,page.PHP,single.PHP,我都不知道。如果有人能提出问题可能在哪里,我可以通过分享代码来提供帮助。
这是index.php
<?php
get_header(); ?>
<div class="wrap blog">
<h1>Blog</h1>
<div class="blog-left">
<div id="main-content" class="main-content">
<?php
if ( is_front_page() && twentyfourteen_has_featured_posts() ) {
// Include the featured content template.
get_template_part( 'featured-content' );
}
?>
<div id="primary" class="content-area">
<div id="content" class="site-content" role="main">
<?php
if ( have_posts() ) :
// Start the Loop.
while ( have_posts() ) : the_post();
/*
* Include the post format-specific template for the content. If you want to
* use this in a child theme, then include a file called called content-___.php
* (where ___ is the post format) and that will be used instead.
*/
get_template_part( 'content', get_post_format() );
endwhile;
// Previous/next post navigation.
twentyfourteen_paging_nav();
else :
// If no content, include the "No posts found" template.
get_template_part( 'content', 'none' );
endif;
?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_sidebar( 'content' ); ?>
</div><!-- #main-content -->
</div>
<div class="blog-right">
<?php get_sidebar(); ?>
</div>
</div>
<?php
get_footer();
查看模板层次结构图,找出用于显示这些帖子的文件。它可能是archive.php、front-page.php、home.php、index.php,具体取决于主题和设置。从那里,您将看到函数或加载哪个文件来显示每个帖子的内容。
考虑到示例代码,它可能在content.php中,或者如果它是一种特殊的post格式,则在content-{format}.php中
我几乎可以肯定,如果主题使用Template Tags,则使用the_date
函数,而应该使用the_time
函数。
你可以阅读the_date
的文档,在描述中有一条你应该阅读的注释。