WordPress.org

Ready to get started?Download WordPress

Forums

get_header() arguments? (4 posts)

  1. WarAxe
    Member
    Posted 8 years ago #

    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?

  2. niziol
    Member
    Posted 8 years ago #

    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.

  3. WarAxe
    Member
    Posted 8 years ago #

    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) ?

  4. niziol
    Member
    Posted 8 years ago #

    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 http://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.

Topic Closed

This topic has been closed to new replies.

About this Topic