• hello,

    I am designing a child theme using Twentyeleven as parent.

    I’d like to add some html elements over the header image: icons to facebook page, twitter accounts etc..

    I could manage it just pasting those icon on the header image and then using an image map, but I prefer to have the img tags called in separate div’s and then styling the absolute positions of these div’s via css.

    I could easily add the div’s to header.php, but I would like to avoid as much as possible adding modified parent’s template files to the child theme.

    The solution I am thinking is to exploit some event (hook or action) to trigger a function in the child’s functions.php to add those html elements in the <body>, but I can’t find a specific action to use.

    I mean, when WordPress core start writing the body, then please write also my div’s and img’s.

    Is this possible, and could someone give me some hint?

    thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • If you’re using a child theme, just copy and paste the header.php file of the parent theme and save that to your child theme. Now edit the header.php file that you just created in your child theme folder and you can just put the divs in there yourself. No need to hook to anything.

    Thread Starter lucaboccianti

    (@lucaboccianti)

    thanks for your answer. I was aware of that and this is the method I normally use.

    maybe I need to clarify my question. I was just thinking: what if the developer of the parent theme update the theme and significantly modify the parent header.php with new functionalities etc.. I would have to rewrite the child header.php.

    ok, no big deal, but maybe delegating the child functions.php to do the job would avoid the necessity of rewriting header.php.

    Ultimately, it’s going to be completely theme dependant. Some themes offer their own filters & actions, other’s don’t. You would need to look for a theme from the first group if you want to modify the header output via functions.php.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘adding header html elements in a child theme with functions.php’ is closed to new replies.