• Resolved PurpleFlower

    (@purpleflower)


    Ok I want to use two different header.php files, one for my index.php and one for everything else. I have tried just creating a second header.php and calling it header2.php and then inserting get_header2() blah into the index.php but it breaks the site if I do that. I tried looking in functions.php to see if it had somewhere to define a new get_header….. function but couldn’t see anything that looked useful. I am also hoping to be able to do this for the footer too if anyone can help I’d really appreciate it. my site is https://blog.purpleflower.co.nz just in case you need to see it. thanks

Viewing 7 replies - 1 through 7 (of 7 total)
  • get_header2() will not work unless you write a function to make it real.
    get_header is a function defined in the WP core files, that’s how it works.
    For any other file you will have to use regular PHP include. For example, including another header should look like:
    <?php include (TEMPLATEPATH . '/myheader.php'); ?>
    (if “myheader” is in the theme folder)
    Is this what you were looking for?

    Thread Starter PurpleFlower

    (@purpleflower)

    yep thank you so much :D, I’m still a beginner at this and don’t really know what I’m doing so thank you for answering questions that must seem a little silly to you.

    There are no silly questions – and we all were “beginners” at some point and we still are in many other areas ??

    I have a little similar question moshu. To avoid hardcoding the TEMPLATEPATH, is there any WordPress keyword that points to the folder of my currently selected template?

    For example, if I want to have some images associated with a particular theme, and I want to keep them in the folder of that theme, do I have to hardcode “www.domain.com/wp-content/themes/themename/images/image.gif”

    Or is there a way I could put in my php something like “TEMPLATEPATH/images/image.gif”?

    Or is TEMPLATEPATH a valid keyword?

    That’s why I gave it to the OP – it’s a “valid keyword”… whatever it means. If it is used in a template file of a theme it points to the theme folder.
    However, for images – since they are not included as is the case with files, I’d go with another code (see Template_Tags/bloginfo); something like:
    <?php bloginfo('stylesheet_directory'); ?>/images/image.jpg

    Okay thanks, that’s what I was after. When I said “valid” I meant a keyword that I could actually use, as opposed to it being a piece of pueudo code you were using to help explain what you meant. Thanks : )

    Just for those that will read this later: for including a file the code I gave in my first reply (with TEMPLATEPATH) should be used exactly as it is posted: do not replace the “TEMPLATEPATH”, change only the name of your file to be included!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘I want to use two different header files how do I do this?’ is closed to new replies.