I know WordPress has a filter for targeting the content in the functions.php file:

add_filter( 'the_content')

However, is there a filter to insert content BEFORE ? 'the_content' filter puts content AFTER div#main. I'm looking for something like:

add_filter( 'before_main')

Does a filter like that exist?

1 Answer 1


The markup surrounding the content is not specified by WordPress, so there is no hook for that.

But you can declare your own hook there. In your template file, write …

do_action( 'before_content_container' );
<div class="main">
do_action( 'after_content_container' );

… and then you can register a callback for that action in your functions.php.

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.