2

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

1 Answer 1

4

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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