Support » Themes and Templates » Difference between php include and wp get_header etc. ?

Difference between php include and wp get_header etc. ?

  • Can anyone tell me if there’s a huge amount of difference between using ‘<?php get_header(); ?>’ and a theoretical
    ‘<?php include(“header.inc”)?>’ ?

    Is it a speed thing?

Viewing 5 replies - 1 through 5 (of 5 total)
  • those are completely different animals.

    <?php get_header(); ?> is calling the function named get_header that is defined elsewhere.

    while, <?php include("header.inc")?> is attempting to include a file named header.inc

    so yes, on the face, theres a huge amount of difference.

    If however, you are are attempting to substitute a file named header.inc for the standard wordpress function, that would work.

    And no there wouldnt be any measurable difference. it would be measured in miliseconds.

    Right, thankyou.

    I should have used get_footer as it would have been easier to explain what I want to do.

    I’ve have hard-coded the same footer across various categories, archives etc. but was thinking of including a standard email address and some tracking code into the bottom of each of these. (Email address and tracking code could change at any time)

    I know we’re only talking about milliseconds, but the milliseconds surely add up, especially if there’s a reasonable amount of traffic?

    The function get_footer effectively seems to do the same thing as an include.

    function get_footer() {
    if ( file_exists( TEMPLATEPATH . ‘/footer.php’) )
    load_template( TEMPLATEPATH . ‘/footer.php’);
    load_template( ABSPATH . ‘wp-content/themes/default/footer.php’);

    Or should I use
    <?php include (TEMPLATEPATH . ‘/footer.inc’); ?>

    get_footer = is a WP specific thing; it is defined in the core files and it works accordingly.

    include (richarduk.php) = is a general PHP thing for including any file

    the TEMPLATEPATH version works only if the non-standard, non-WP template file is located in the theme folder

    Thanks 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Difference between php include and wp get_header etc. ?’ is closed to new replies.