更改我的Wordpress网站上的时间戳

时间:2017-01-30 21:51:22

标签: php wordpress date timestamp

在google SERP中,我的时间戳是我文章的创建日期,但在我定期更新时,我想显示更新日期。我读到谷歌使用它找到的第一个日期,这是我的创建日期(更新日期写在那之后)。

我想在代码中更改

而不是这个顺序:

创建于:2010年7月2日,更新于:2016年7月5日

我想创建以下内容:

更新时间:2016年7月5日,创建时间:2010年7月2日

基本上只需切换两个日期,以便谷歌选择正确的日期。

在我的page.php上写了以下内容

                <div class="blog_info contentsbox <?php st_hidden_class(); ?>">
                <p>Created on:
                    <time class="entry-date" datetime="<?php the_time(DATE_W3C); ?>">
                        <?php the_time( 'Y/m/d' ); ?>
                    </time>
                    <br>
                    <?php if ( $mtime = st_get_mtime( 'Y/m/d' ) ) {
                        echo 'Updated on:', $mtime;
                    } ?>
                </p>
            </div>

在我的单身PHP:

                    <div class="blogbox <?php st_hidden_class(); ?>">
                    <p><span class="kdate"><i class="fa fa-calendar"></i>&nbsp;
            <time class="entry-date date updated" datetime="<?php the_time(DATE_W3C); ?>">
                <?php the_time( 'Y/m/d' ); ?>
            </time>
            &nbsp;
                            <?php if ( $mtime = st_get_mtime( 'Y/m/d' ) ) {
                                echo ' <i class="fa fa-repeat"></i>&nbsp; ', $mtime;
                            } ?>
            </span></p>
                </div>

提前感谢您的帮助

1 个答案:

答案 0 :(得分:0)

<div class="blog_info contentsbox <?php st_hidden_class(); ?>">
    <p>
        <?php if ( $mtime = st_get_mtime( 'Y/m/d' ) ) {
            echo 'Updated on:', $mtime;
        } ?>
        <br>
        Created on:
        <time class="entry-date" datetime="<?php the_time(DATE_W3C); ?>">
            <?php the_time( 'Y/m/d' ); ?>
        </time>                        
    </p>
</div>

和另一个:

<div class="blogbox <?php st_hidden_class(); ?>">
    <p>
        <span class="kdate"><i class="fa fa-calendar"></i>&nbsp;
            <?php if ( $mtime = st_get_mtime( 'Y/m/d' ) ) {
                echo ' <i class="fa fa-repeat"></i>&nbsp; ', $mtime;
            } ?>
            &nbsp;
            <time class="entry-date date updated" datetime="<?php the_time(DATE_W3C); ?>">
                <?php the_time( 'Y/m/d' ); ?>
            </time>
        </span>
    </p>
</div>