I have multiple header files, which are 90% the same code. It would make editing them easier if common code could be contained and called from a separate file.

However, neither "include" nor "get_template_part" do not appear to work in header.php. How could this be managed?

  • 2
    Include should work fine. Can you show us what you're trying? – Rup Mar 3 at 11:21
  • 4
    get_template_part() should also work fine in header.php, please share your code – kero Mar 3 at 11:27
  • Yep, apologies: one of those days where you try 90 things and the first thing actually worked without you noticing. – JohnG Mar 4 at 10:45

Your Answer

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

Browse other questions tagged or ask your own question.