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 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:

while(has_post()) {

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; } ?>