【问题标题】:WordPress blog dates are displaying the current date for every postWordPress 博客日期显示每个帖子的当前日期
【发布时间】:2014-09-09 17:22:09
【问题描述】:

运行自定义主题的我的 WordPress 博客将每个条目帖子的日期显示为同一日期:今天。我在我的主页上显示最后三个帖子,但这些日期很好。但是,我的主博客页面显示了每篇文章的当前日期。

我能够通过 FTP 进入我的站点,并且可以访问所有 PHP 文件,问题是我不知道这个错误可能在哪个文件中,无论是 index.php、page.php 还是单个。 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();

【问题讨论】:

  • 可以加代码吗?
  • 这就是问题所在,我不知道那个代码会在哪里......我只是点击了常规 -> 设置以在我的页面上显示最新的 10 个帖子,wordpress 就可以了。但它显示的日期错误...
  • 尝试添加index.php 文件,如果可以,只需添加while 内的部分并调用have_post 函数
  • “我的主博客页面” - 如果您指的是单独显示帖子的页面,这很可能是“single.php”。虽然可以在服务器上修复此问题,但最好在本地下载、修复,然后在确定可以正常工作时上传。
  • 它实际上在 content.php 中,我只需要跟踪所有的调用,它就到了那里,得到了修复!!感谢所有的帮助

标签: php html wordpress date blogs


【解决方案1】:

查看模板层次结构图,找出用于显示这些帖子的文件。它可能是archive.php、front-page.php、home.php、index.php,具体取决于主题和设置。从那里,您将看到函数或加载了哪个文件来显示每个帖子的内容。

考虑到示例代码,它可能在 content.php 中,或者如果它是一种特殊的帖子格式,在 content-{format}.php 中

【讨论】:

  • 你是对的!!它在 content.php 中,我将它从 echo date 切换到 echo the_time('F, Y');
【解决方案2】:

我几乎可以肯定,如果主题使用模板标签,使用the_date 函数,什么时候应该使用the_time函数。

您可以阅读the_date 的文档,在说明中有一条您应该阅读的说明。

【讨论】:

  • 您是否知道这些模板标签在哪里/什么文件被调用?
猜你喜欢
  • 2017-06-20
  • 2021-03-18
  • 1970-01-01
  • 2018-02-04
  • 1970-01-01
  • 1970-01-01
  • 2017-10-02
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多