Get content post by id wordpress, lấy nội dung bài viết theo id bài như thế nào?

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

  1. seolagi
    Tham gia ngày:
    16/4/14
    Bài viết:
    1,048
    Đã được thích:
    82
    Điểm thành tích:
    48
    hi mọi người, giúp em: Get content post by id wordpress, lấy nội dung bài viết theo id bài như thế nào?

    Em có cái postid = 100, giờ em muốn lấy nội dung bài viết đó ra thì làm như thế nào?

    Em xài themes flatsome mới nhất. Cảm ơn
     
    Cảm ơn đã xem bài:

    Get content post by id wordpress, lấy nội dung bài viết theo id bài như thế nào?

  2. admin
    Tham gia ngày:
    22/5/13
    Bài viết:
    5,047
    Đã được thích:
    1,227
    Điểm thành tích:
    113
    Giới tính:
    Nam
    Có 3 cách lấy nội dung bài viết như sau nhé:

    Cách 1:
    PHP:
    $content_post = get_post($post_id);
    $content = $content_post->post_content;
    $content = apply_filters('the_content', $content);
    $content = str_replace(']]>', ']]>', $content);
    Cách 2:
    PHP:
    $content = get_post_field('post_content', $post_id);
    Cách 3:
    PHP:
    $content = apply_filters('the_content', get_post_field('post_content', $post_id));
     
    seolagi thích bài này.


Chủ để tương tự : content post
Diễn đàn Tiêu đề Date
Mã nguồn mở Wordpress Add tag p to content view in post wordpress 2/9/20
Mã nguồn mở Wordpress Get the Content Product woocommerce, lấy nội dung sản phẩm như thế nào? 29/3/22
Mã nguồn mở Wordpress Lấy content bài viết, sản phẩm và xóa tất cả mã html như thế nào? 29/1/21
Mã nguồn mở Wordpress Sticky Posts not working themes Flatsome, sticky Post không hoạt động trên Flatsome 25/4/24
Mã nguồn mở Wordpress Get all post by meta key or value, get meta value by post id wordpress 7/7/22