WordPress.org

Ready to get started?Download WordPress

Forums

Difference between get_header() and include (TEMPLATEPATH . "/header.php"); (2 posts)

  1. notknow
    Member
    Posted 4 years ago #

    I have a header.php with some custom php to find out which group a page belongs to, i save this gruop name into a var.

    When using get_header(); in my main template file i cannot read the content of that var while when using include (TEMPLATEPATH . "/header.php") i have the value at hand.

    get_header calls do_action which is a function i do not understand with my current knowledge of WordPress.

    This is not a "real" problem as i obviously can use "include" but i would like to understand why this happens. Someone willing and capable of explaining this?

  2. WP Voyager
    Member
    Posted 4 years ago #

    @notknow: Wow, that's a good question! I have been working with the whole template tag system recently, trying to find some solutions for my site, and I would really like to know the difference also.

    I'm sure it has something to do with the fact that get_header() is a WP function, while include("whatever") is a PHP function.

    Since get_header()is defined by WordPress, it doesn't necessarily follow the same approach as include(). It probably calls that do_action thing as part of the open modularity of WordPress. That whole modularity issue is the whole reason to have a separate header.php in the first place: it allows a persistent header for navigation, and it is a convenient place for plugins to "hook" in order to attach to every page.

    Oh well, those are still just speculations. I would appreciate it if someone knowledgeable about this whole thing could explain it for us!

    Thank you,
    MindBlender 3D

Topic Closed

This topic has been closed to new replies.

About this Topic