• I am working with a site for a local business which has multiple locations. We’re using a premium theme which has a custom option to input our phone number into the header. The issue is we want a different phone number for certain pages. If I leave the custom theme option for the phone number blank, it’ll show up blank on the site.

    I know very little about coding, so I’m hoping this is easily doable. Is there a way to create 2 separate header.php files and tell certain pages to draw from say, header2.php (which would have the different phone number hard coded into it) ?

    Or any other solutions/plugins?

    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator bcworkz

    (@bcworkz)

    It’s difficult to have multiple header files. A better approach anyway is to use a switch/case structure to output various phone numbers based on some condition.

    If possible, create a child theme to contain you custom header so your changes are not lost during a theme update. (Some commercial themes are child themes themselves using a common parent, you cannot have grandchild themes).

    We can’t give you any more specific advice because we don’t know anything about commercial themes. We require open source access to provide specific advice.

    Thread Starter josh5723

    (@josh5723)

    Interesting. The switch/case structure seems like the easiest way to do it (not for me, I mean, I don’t know anything about coding).

    An obvious difference between the pages in question would be the address in the footer will be unique to them. Is it possible to use the switch/case structure within the phone number area in the header.php code to say, “Display 555-555-5555 if ‘200th ST’ is present, otherwise 555-555-5554” or something?

    Moderator bcworkz

    (@bcworkz)

    Well, the footer is a completely different template file, so any code values on that file is not necessarily available on the header file.

    However, there’s probably data somewhere that’s telling the footer to display this address or that address. The header could likely access the same data in order to decide which phone number to display.

    I would expect there is something the switch/case structure can use to output the right phone number, but there is not any way I could specifically tell you exactly what that would be.

    Thread Starter josh5723

    (@josh5723)

    I got this to work by editing the code to display a different header file (a duplicate of the original but with the new phone number in it) for each page I wanted. It was pretty easy after Googling.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Custom Header (Text, Not Image) Per Page?’ is closed to new replies.