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.

I'd like to add content directly after the div#main (end of header.php) and before /div#main (beginning of footer.php).

I'm using an own child-template (of twentythirteen), that contains only style.css and functions.php at the moment.

I added the following content to my functions.php

function myAddedStuff() {
    echo "Stuff";
}
add_action( 'get_header', 'myAddedStuff' );
add_action( 'get_footer', 'myAddedStuff' );

For the footer it works well, since myAddedStuff() is executed, before get_footer. But for get_header I'd like to execute myAddedStuff() afterwards. How can I do that.

Should I use an alternative hook? How can I easily find hooks? Is the an easy way to add contents to certain HTML commands? (e.g. use div#main as a "hook").

share|improve this question
add comment

1 Answer 1

I don't see any hook available to do so. As you are using Child theming, it would be best for you to take a copy of the header.php in the child theme folder and edit it as per your need.

share|improve this answer
    
I'd really like to avoid copy-paste of existing code. I could include it using PHP-functions, but I'm conviced that there is a provided way. I thaught there is a parameter "add_before" or "add_after" in add_action(), but I didn't find it. –  Sven Nov 5 '13 at 8:00
    
Here are your Filters. And here are your Actions. –  josh Nov 5 '13 at 8:13
    
@sven I am afraid, we don't have any hooks for this case. Still let me look more into this and I am sure if we have any hooks, guys here will bring that up. –  Maruti Mohanty Nov 5 '13 at 8:22
    
I think the add_before and add_after are features of Genesis Framework so unless you're using a Studiopress Theme you won't have access to these, but if you do, the Genesis Simple Hooks plugin should do exactly what you want. –  TomC Nov 5 '13 at 9:13
    
I also thought of using jQuery. The content I'd like to add requires JavaScript, anyway. I didn't manage to use jQuery within wordpress, although it seems to be included. I added for example <script> $( "h1" ).remove() </script> to my footer, but still all h1's are shown. I never worked with jQuery before, but this should work,... –  Sven Nov 5 '13 at 11:25
show 1 more 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.