Как вывести дату изменения/обновления записи в админке в блоке Опубликовать

Добавьте в файл functions.php следующий код:



/**
 * Добавление даты изменения в метабокс "Опубликовать"
 */
add_action('post_submitbox_misc_actions', 'show_modified_date_in_publish_box');
function show_modified_date_in_publish_box($post) {
    // Только для записей
    if ($post->post_type !== 'post') {
        return;
    }
    
    // Не показываем для черновиков
    if ($post->post_status === 'auto-draft') {
        return;
    }
    
    $modified_date = get_the_modified_date('d.m.Y', $post->ID);
    $modified_time = get_the_modified_time('H:i', $post->ID);
    $published_date = get_the_date('d.m.Y', $post->ID);
    $published_time = get_the_time('H:i', $post->ID);
    
    ?>
    <div class="misc-pub-section misc-pub-modified" style="border-top: 1px solid #ddd;">
        <span class="dashicons dashicons-edit" style="color: #82878c; margin-right: 5px;"></span>
        Опубликовано в: <strong><?php echo esc_html($published_date); ?></strong> в <strong><?php echo esc_html($published_time); ?></strong>
        <br>
        <span class="dashicons dashicons-update" style="color: #0073aa; margin-right: 5px;"></span>
        Изменено: <strong style="color: #0073aa;"><?php echo esc_html($modified_date); ?></strong> в <strong style="color: #0073aa;"><?php echo esc_html($modified_time); ?></strong>
    </div>
    <?php
}
guest
Другие сообщения форума
Закрыть меню
ZAPLATA.RU | Магазин готовых блогов Wordpress с автонаполнением
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.