WordPress the_content() Function

Definition
In WordPress, the_content() prints the main body of the current post, the text you write in the editor. It is the most used tag in a theme.
It adds paragraphs, runs shortcodes and blocks, and handles the More tag. Use it inside The Loop.
Syntax
A few ways to call the_content().
<?php
while ( have_posts() ) : the_post();
the_content();
endwhile;
| Call | What it does |
|---|
the_content() | Print the post body. |
the_content( 'Read more' ) | Use your own text for the More link. |
get_the_content() | Return the raw content, without filters. |
apply_filters( 'the_content', get_the_content() ) | Return the content with filters applied. |
It prints the content after all filters ran. On a list page it stops at the More tag and adds a link.
Full declaration
the_content( string $more_link_text = null, bool $strip_teaser = false ): void
Parameters
| Parameter | Description |
|---|
$more_link_text | string. The text of the More link. Default is (more...) with the post title for screen readers. |
$strip_teaser | bool. true hides the text before the More tag. Default is false. |
Return Value
| Return Value | Description |
|---|
| void | Nothing is returned. The content is printed. |
WordPress Examples
Three short examples. Each one shows the code and what it prints.
Example 1 — Print the post body
Show the content inside The Loop.
<?php while ( have_posts() ) : the_post(); ?>
<h1><?php the_title(); ?></h1>
<div class="entry">
<?php the_content(); ?>
</div>
<?php endwhile; ?>
<h1>Hello World</h1>
<div class="entry">
<p>Welcome to WordPress. This is your first post.</p>
</div>
How It Works
the_post() sets up the current post.the_content() prints the post body with paragraphs.- The wrapper
div is ours.
Example 2 — Change the More link text
On a list page, the post stops at the More tag. Pass text for the link.
<?php the_content( 'Continue reading' ); ?>
<p>This is the first part of the post.</p>
<p><a href="https://example.com/hello-world/#more-1" class="more-link">Continue reading</a></p>
How It Works
- The author placed a More tag in the editor.
- On a list page the text after it is hidden.
- A link with your text is printed instead.
Example 3 — Get the content as text
Use get_the_content() when you need to work with it, for example to count words.
<?php
$text = wp_strip_all_tags( get_the_content() );
$words = str_word_count( $text );
echo 'About ' . intval( $words ) . ' words';
How It Works
get_the_content() returns the content as a string.wp_strip_all_tags() removes HTML tags.str_word_count() counts the words.
Frequently Asked Questions
It prints the main body of the current post with paragraphs, blocks, and shortcodes processed.
Yes. the_content() works on the current post of The Loop.
the_content() prints the full post. the_excerpt() prints a short summary.
On a list page, the post is cut at the More tag and a link to the full post is printed.
Use get_the_content(). Apply the the_content filter if you also want shortcodes and paragraphs.
Browse all post functions
Open the functions index for simple guides with examples and FAQs.
Post Functions Index →About the author
Developer, cloud engineer, and technical writer
I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.
8 people found this page helpful