Grow your CSS skills. Land your dream job.

I have 8 header.php variations in WordPress. I must be doing something wrong.

  • # November 16, 2011 at 3:04 pm

    Every time I create a new page template in WordPress – for example category-news.php, or single-portfolio.php, I duplicate my header.php to call custom javascript libraries that won’t be used elsewhere on the site.

    so in category-news.php, I call my header like this: get_header(news);
    and in single-portfolio.php, I call my header like so: get_header(portfolio);

    Then I create header-news.php and header-portfolio.php in which 85% of the code is the same. Now when I want to make a single change to my header, I have to change it in multiple files. It seems like I MUST be doing something wrong.

    Is there a way to *extend* my header to keep “all the basics” + these two jquery plugins for a given post template?

    Thanks for any advice. A google search is making me feel like I’m the only person in the world who has this problem so I must be missing something obvious, Thank, Matth

    # November 16, 2011 at 3:15 pm

    Hmm… off the top of my head php variables is one way. An example:

    header.php





    < ?php echo $pageSpecific; ?>

    single-portfolio.php (at top of document)



    < ?php $pageSpecific='