Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question
add comment

1 Answer 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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.