WordPress.org

Ready to get started?Download WordPress

Forums

get_header vs. include header.php (4 posts)

  1. WarAxe
    Member
    Posted 8 years ago #

    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?

  2. moshu
    Member
    Posted 8 years ago #

    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.

  3. niziol
    Member
    Posted 8 years ago #

    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,
    Michael.

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

  4. WarAxe
    Member
    Posted 8 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic