Function to wrap the_content in a div

Whenever I’ve developing a new theme I always wrap the_content in a div, like so;

<div class="entry-content">
    <?php the_content();?>
</div>

Is there a way I can streamline this process and automatically wrap the_content in a div via a function so I don’t always have to manually code it and, more importantly, so if my client ever feels like flexing their coding muscles there wont be a problem if they forget to do it…

Related posts

1 comment

  1. You can hook the_content filter.

    paste below code in functions.php :

    <?php
     add_action('the_content','ravs_content_div');
     function ravs_content_div( $content ){
      return '<div class="entry-content">'.$content.'</div>';
     }
    ?>
    

    After paste this code in functions.php, the_content() print post/page content after wrap content in div with class entry-content.

Comments are closed.