Forums

[resolved] include templatepath function (6 posts)

  1. ronchicago
    Member
    Posted 10 months ago #

    1) this is the code to get an alternate header =

    <?php include (TEMPLATEPATH . '/header2.php'); ?>

    2) i moved a file outside of the wp directory and that file is now looking for header2.

    i tried this but it does not work =

    <?php include (TEMPLATEPATH . 'http://www.domain.com/wp-content/themes/theme/header2.php'); ?>

  2. iridiax
    Member
    Posted 10 months ago #

    TEMPLATEPATH is the template URL (http://www.domain.com/wp-content/themes/theme) and the period is concatenation, which means that the template URL is added to whatever follows it.

  3. ronchicago
    Member
    Posted 10 months ago #

    i understand the function and concatenation. it would seem an absolute path would find the header.php but then, again, maybe i don't understand.

    i get these error codes, i.e., can't find header2.php

    Warning: main(TEMPLATEPATH/header2.php) [function.main]: failed to open stream: No such file or directory in /home/code/public_html/enter.php on line 18

    Warning: main() [function.include]: Failed opening 'TEMPLATEPATH/header2.php' for inclusion (include_path='.:/usr/php4/lib/php:/usr/local/php4/lib/php') in /home/code/public_html/enter.php on line 18

  4. iridiax
    Member
    Posted 10 months ago #

    TEMPLATEPATH is a special WordPress function, so it can only be used within WordPress. Try a regular php include instead.

  5. ronchicago
    Member
    Posted 10 months ago #

    tried it both ways - both in and out of wp - and moved the file back inside wp, though in the wp root and the wp-contents.

    thanks iridiax

  6. drmanry
    Member
    Posted 10 months ago #

    ronchicago,

    Since you're supplying an absolute path, just use
    <?php include ('http://www.domain.com/wp-content/themes/theme/header2.php'); ?>

Reply

You must log in to post.

About this Topic