How to display page content in Wordpress

Jeff Boolean

The function to output page's content in Wordpress is the_content(). This function accepts no argument:

the_content();

The the_content function simply outputs the HTML content of a post. Since a page is a special type of post, if we call this function on a template page it will return the page HTML content.

Remember to wrap this function inside the loop:

<?php
while(has_post()) {
the_post();
the_content();
?>

Or if you want to add more HTML before and after the page content:

<?php while (has_post()) : the_post(); ?>
    <!-- HTML before content -->
    <?php the_content; ?>
    <!-- HTML after content -->
<?php endwhile; } ?>

Reply