Get author info by post id wordpress như thế nào?

Thảo luận trong 'Mã nguồn mở Wordpress' bắt đầu bởi seolagi, 2/11/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
    Mình đang làm cái code trong function.php của themes thì cần lấy thống tin email của người viết bài, giờ làm sao để lấy được thông tin này khi có post id của bài viết rồi.
    Giờ làm sao để lấy các thông tin author info như: email author, link author, name author của người viết bài.
     
    Cảm ơn đã xem bài:

    Get author info by post id wordpress như thế nào?

  2. admin
    Tham gia ngày:
    22/5/13
    Bài viết:
    4,907
    Đã được thích:
    1,200
    Điểm thành tích:
    113
    Giới tính:
    Nam
    Của bạn đây nhé, khi biết post_id của bài viết thì dùng code sau để lấy thông tin:
    PHP:
    $post get_post$post_id );
    $author_id $post->post_author;
    echo 
    get_the_author_meta'display_name'$author_id); 
    echo 
    get_the_author_meta'user_email'$author_id);
    Xem toàn bộ các biên như sau:
    • admin_color
    • aim
    • comment_shortcuts
    • description
    • display_name
    • first_name
    • ID
    • jabber
    • last_name
    • nickname
    • plugins_last_view
    • plugins_per_page
    • rich_editing
    • syntax_highlighting
    • user_activation_key
    • user_description
    • user_email
    • user_firstname
    • user_lastname
    • user_level
    • user_login
    • user_nicename
    • user_pass
    • user_registered
    • user_status
    • user_url
    • yim
     
    seolagi thích bài này.
  3. 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
    Thanks, em áp dụng code trên và đã lấy được email của người post bài rồi ạ
     


Chủ để tương tự : author info
Diễn đàn Tiêu đề Date
Mã nguồn mở Wordpress Get author id from page author detail wordpress 29/11/21
Mã nguồn mở Wordpress Hiển thị avatar author bài viết với WP User Avatar trong wordpress 10/1/18