Get Post time date Modification and publish by post_id in wordpress

Thảo luận trong 'Mã nguồn mở Wordpress' bắt đầu bởi seolagi, 30/10/21.

  1. seolagi
    Tham gia ngày:
    16/4/14
    Bài viết:
    1,030
    Đã được thích:
    81
    Điểm thành tích:
    48
    Get last date update Modification of post in wordpress, Get time date Modification of post in wordpress, lấy thời gian cập nhật trong wordpress, lấy thời gian edit cập nhật, sửa bài viết trong wordpress, code lấy thời gian edit, thời gian sửa bài của bài viết trong wordpress như thế nào? get last update time post by post_id in wordpress, get post publish date by post_id in wordpress, lấy ngày viết bài của bài viết theo id bài viết.

    Lấy Post Modified theo post_id
    PHP:
    echo get_post_modified_time('l, F jS, Y'true$post->IDfalse);
    • Kết quả: Monday, October 30th, 2021
    PHP:
    echo get_post_modified_time('l, F jS, Y \a\t g:i a'true$post->IDfalse);
    • Kết quả: Monday, October 30th, 2021 at 11:53 am
    PHP:
    echo get_post_modified_time('d/m/Y g:i'true$postidfalse);
    • Kết quả: 30/11/2021 11:53
    Lấy Post Publish theo post_id

    Get post publish date by post_id in wordpress, muốn lấy ngày viết thì sử dụng code sau tương tự như ngày cập nhật, chỉ khác tên hàm thôi.
    PHP:
    echo get_the_time('Y-m-d'$post->ID);
    PHP:
    echo get_the_time('d/m/Y g:i'$post->ID);
    Cách khác 2
    PHP:
    //get the local time of the current post in seconds
    $local_timestamp get_the_time('U');

    //get the time when the post was last modified
    $lastModifiedTime get_the_modified_time('U');

    if (
    $lastModifiedTime >= $local_timestamp 86400) {
       echo 
    "<p>Last modified on ";
       
    the_modified_time('F jS, Y');
       echo 
    " at ";
       
    the_modified_time();
       echo 
    "</p> ";
    }
    Cách 3:
    PHP:
    function lastModifiedAt$postContent ) {
        
    //get the local time of the current post in seconds
        
    $local_timestamp get_the_time('U');

        
    //get the time when the post was last modified
        
    $lastModifiedTime get_the_modified_time('U');

        if (
    $lastModifiedTime >= $local_timestamp 86400) {
            
    $modifiedDate get_the_modified_time('F jS, Y');
            
    $modifiedTime get_the_modified_time('h:i a');
            
    $updatedInfo '<p class="last-updated">Last modified on '$modifiedDate ' at '$modifiedTime .'</p>';
        }
     
        
    $updatedPostContent $updatedInfo $postContent;
        return 
    $updatedPostContent;
    }
    add_filter'the_content''lastModifiedAt' );
    Cách 4:
    PHP:
    $u_time get_the_time('U');
    $u_modified_time get_the_modified_time('U');
    if (
    $u_modified_time >= $u_time 86400) {
    echo 
    "<p>Last modified on ";
    the_modified_time('F jS, Y');
    echo 
    " at ";
    the_modified_time();
    echo 
    "</p> "; } 
    Cách 5:
    PHP:
    function wpb_last_updated_date$content ) {
    $u_time get_the_time('U');
    $u_modified_time get_the_modified_time('U');
    if (
    $u_modified_time >= $u_time 86400) {
    $updated_date get_the_modified_time('F jS, Y');
    $updated_time get_the_modified_time('h:i a');
    $custom_content .= '<p class="last-updated">Last updated on '$updated_date ' at '$updated_time .'</p>';
    }
     
        
    $custom_content .= $content;
        return 
    $custom_content;
    }
    add_filter'the_content''wpb_last_updated_date' );
     
    Cảm ơn đã xem bài:

    Get Post time date Modification and publish by post_id in wordpress

    Last edited by a moderator: 30/10/21
    admin thích bài này.


Chủ để tương tự : Post date
Diễn đàn Tiêu đề Date
Mã nguồn mở Wordpress Sticky Posts not working themes Flatsome, sticky Post không hoạt động trên Flatsome Thứ năm lúc 10:45 PM
Mã nguồn mở Wordpress Get all post by meta key or value, get meta value by post id wordpress 7/7/22
Mã nguồn mở Wordpress How to Get Total Number of Posts by user id Wordpress 13/6/22
Mã nguồn mở Wordpress Get excerpt post in wordpress, lấy mô tả bài bài viết như thế nào? 23/3/22
Mã nguồn mở Wordpress Get author info by post id wordpress như thế nào? 2/11/21