• Is it possible to pass arguments to my header.php using the get_header() function?

    Here’s why I ask. I’m having a devil of a time trying to make sure my highlighted navigation menu knows when I have a post showing from a certain category. (e.g. Perhaps I want my menu to highlight ‘FLASH’ if I have a post that is of the category ‘Flash’) To complete this seemingly monumental and insane task, that it looks like I’m the first person anywhere in the history of the world to want to do, I have a way to do it if I can pass a variable to my header.php from my single.php.

    Ideas?

Viewing 3 replies - 1 through 3 (of 3 total)
  • I’ve posted a solution to what you’re seeking to do in this thread, the code I put up on pastebin was done up for that particular thread, but you should be able to modify it to fit your needs. Let me know if you need any help.

    Cheers,
    Michael.

    Thread Starter waraxe

    (@waraxe)

    Michael,

    The pastbin keeps timing out on me. Is there anywhere else?

    Here’s a question. Even if I have some standard permalink turned on… (like mysite.com/archives/153)… is there a _URL variable or _SERVER variable (or even a tag for that matter) that will tell me what template file was used (e.g. category-24.php) ?

    Pastebin seems to hate me for some reason – it’s working right now, but I’ve posted the code here on my website for you.

    The script works by getting the requested URI, which for https://www.example.com/home would be /home and compares that to the $homepage which you set in the code. I just made it to highlight my non-WP homepage link, so it just does one comparision, but you can adapt it to do exactly what you’d like. The code is commented, so it’s self-explanatory.

    Give it a go and feel free to ask for assistance if you get stuck!

    Cheers,
    Michael.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘get_header() arguments?’ is closed to new replies.