get_the_content() WP 0.71
Gets the content of the current post. Must be used inside the WordPress loop.
Does not filter content as the_content() does. Therefore, if you want to get the result by applying all the_content hooks to the content, use this construction:
apply_filters( 'the_content', get_the_content() );
- Global. Int.
$page
Page number of a single post/page. - Global. Int.
$more
Boolean indicator for whether single post/page is being viewed. - Global. true/false.
$preview
Whether post/page is in preview mode. - Global. Array.
$pages
Array of all pages in post/page. Each array element contains part of the content separated by the <!--nextpage--> tag. - Global. Int.
$multipage
Boolean indicator for whether multiple pages are in play.
Is the basis for:
get_the_content_feed()
, the_content()
✈ 1 time = 0.005081s = very slow | 50000 times = 3.32s = fast | PHP 7.2.5, WP 4.9.6
Hooks in function
Return
String. Post content.
Usage
$content = get_the_content( $more_link_text, $strip_teaser );
- $more_link_text(string)
- The text of the "read more" link. This link is added when the post content has html comment
<!--more-->
and when this function uses on any archive page (not single page).
Default:null
- $strip_teaser(true/false)
Do we need strip content before the
<!--more-->
tag when the content is shown on singular page. The word "teaser" means attractive text before the<!--more-->
tag.By default this parameter is disabled. It can also be enabled by specifying anywhere in the post content
<!--noteaser-->
html comment (usually, it specified immediately after the<!--more-->
).
Default: false
Examples
#1 Get the content of the post
Output the content of the post with the link "read more" where necessary:
<?php $content = get_the_content('read more'); echo apply_filters( 'the_content', $content ); ?>
Code of get the content:
wp-includes/post-template.php
VER 5.0.3
Related Functions
From tag: WP Loop
More from category: Posts, pages...
- edit_post_link()
- get_delete_post_link()
- get_edit_post_link()
- get_permalink()
- get_post_field()
- get_post_status()
- get_post_time()
- get_the_date()