Codex tools: Log in / create account
Contents |
Hiển thị nội dung bài viết hiện tại. Thẻ này phải nằm trong Vòng_lặp.
Nếu thẻ <!--more--> được sử dụng trong một bài viết, thẻ the_content() sẽ chỉ hiển thị phần nội dung phía trên của <!--more-->. Thẻ the_content() đi kèm với tham số cho phép định dạng nội dung thẻ <!--more-->, hay liên kết để "đọc tiếp" phần còn lại của bài viết.
<?php the_content ( 'more_link_text', strip_teaser, 'more_file');?>
Ngoài ra, bạn có thể sử dụng hàm get_the_content để lấy nội dung giá trị thay vì hiển thị nó trực tiếp. Ví dụ:
<?php $content = get_the_content(); ?>
Please note! get_the_content will not have the following done to it and you are advised to add them until the core has been updated:
<?php
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
?>
Displays the content of the post and uses "Read more..." for the more link text when the <!--more--> Quicktag is used.
<?php the_content('Read more...'); ?>
Similar to the above example, but thanks to the_title() tag and the display parameter, it can show "Continue reading ACTUAL POST TITLE" when the <!--more--> Quicktag is used.
<?php the_content("Continue reading " . the_title('', '', false)); ?>
If the_content() isn't working as you desire (displaying the entire story when you only want the content above the <!--more--> Quicktag, for example) you can override the behavior with global $more.
<?php // Declare global $more, before the loop. global $more; ?>
<?php
// Display content above the more tag
$more = 0;
the_content("More...");
?>
Alternatively, if you need to display all of the content:
<?php // Declare global $more, before the loop. global $more; ?>
<?php // Display all content, including text below more $more = 1; the_content(); ?>
note: in my case I had to set $more=0; INSIDE the loop for it to work.
the_ID, the_title, the_title_attribute, single_post_title, the_title_rss, the_content, the_content_rss, the_excerpt, the_excerpt_rss, wp_link_pages, next_post_link, next_posts_link, previous_post_link, previous_posts_link, posts_nav_link, sticky_class, the_meta