Показывать время последнего обновления вместо времени публикации - PullRequest
0 голосов
/ 06 октября 2018

Я очень новичок в Php.Я хочу показать дату последнего обновления вместо времени публикации.Кто-нибудь может мне помочь?Большое спасибо.

    if ( ! function_exists( 'minimalistblogger_posted_on' ) ) :
    function minimalistblogger_posted_on() {
        $time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
        if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
            $time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';
        }

        $time_string = sprintf( $time_string,
            esc_attr( get_the_date( 'c' ) ),
            esc_html( get_the_date() ),
            esc_attr( get_the_modified_date( 'c' ) ),
            esc_html( get_the_modified_date() )
        );

        $posted_on = sprintf(
            esc_html_x( 'Posted on %s', 'post date', 'minimalistblogger' ),
            '<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>'
        );

        $byline = sprintf(
            esc_html_x( 'by %s', 'post author', 'minimalistblogger' ),
            '<span class="author vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . esc_html( get_the_author() ) . '</a></span>'
        );

        echo '<span class="posted-on">' . $posted_on . '</span><span class="byline"> ' . $byline . '</span>'; // WPCS: XSS OK.

    }
endif;

1 Ответ

0 голосов
/ 06 октября 2018

Ах!Я нашел это!

Просто используйте

get_the_modified_time ('F d, Y');

$ifiedtime = get_the_modified_time ('F d, Y');$ posts_on = sprintf (esc_html_x ('Последнее изменение на% s', 'дата публикации', 'minimalistblogger'), ''. $ updatedtime. '');

спасибо:)

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...