Support » How-To and Troubleshooting » get_header vs. include header.php

get_header vs. include header.php

  • I noticed that get_header() acts differently from include(‘header.php’). For instance, when using a state variable to tell my navbar which menu item to mark highlighted I have to INCLUDE my header (it’s actually my footer that has the navbar but no matter)… because if I just use get-header() it doesn’t see the variable.

    There must be a difference in when the php is interpretted by the server.

    Here’s a question: if I php include a file with php… can I then (in the included file) include another file with php… and so on… ? Will the server know to not stop interpretting all of these php tags until it’s done them all… and ONLY THEN send it to my browser?

Viewing 3 replies - 1 through 3 (of 3 total)
  • 1. get_header is a function written in the WP files.
    include ('header.php') is a normal PHP thingy.
    [now you can so how much a coder I am ;)]

    2. Have no idea.

    I’m not sure if the only issue is having an indication in the menus, but in this post I posted a bit of code I use to highlight the nav-bar for pages WordPress normally wouldn’t, not sure if that would be of help, but there it is anyway.

    Good luck,

    PS: I do believe you can have nested includes with PHP 🙂

    niziol :: Yeah, this is similar to the discussion we had before. I knew the code to highlight, but I had trouble finding, in every situation, some definitive indicating factor I could use php to determine which menu item needed highlighting.

    Yeah, I think you’re right about the nested php includes… because I’m already doing one nest (including header.php, which itself has plenty of php in it) and it’s working.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘get_header vs. include header.php’ is closed to new replies.
Skip to toolbar