0

Currently my article is displayed like this:

<div class="post_modul border_b">             

 <div id="attachment_61891" class="wp-caption alignnone" style="width: 478px">
    <img class="size-full wp-image-61891 colorbox-78559"
 </div>

 <!-- now article body starts -->
 <p>
  blabla
 </p> 

</div>

I want to modify the_content() function so that body is wrapped around a div with an id, so that I can easily refer to it. My desired output:

<div class="post_modul border_b">             

 <div id="attachment_61891" class="wp-caption alignnone" style="width: 478px">
    <img class="size-full wp-image-61891 colorbox-78559"
 </div>

 <!-- now article body starts -->
 <div id="content_body">
 <p>
  blabla
 </p> 
 </div>
</div>

How to obtain this behaviour? What file do I have to modify?

  • 1
    You have to find your template yourself. Take a look at the Template Hierarchy, find the file and then come back to make an edit and show your templates code. No one will be able to guess which template or template part is in use. This will highly depend on your theme and there're thousands of them outside. – kaiser Oct 29 '12 at 10:44
3

You could try something like

<?php

add_filter('the_content','wrap_content');

function wrap_content($content) {

    $content = '<div id="YOURID">'.$content.'</div>';

    return $content;
}
?>

Just add it into your functions.php file Untested code

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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