WordPress.org

Ready to get started?Download WordPress

Forums

ABSPATH to header php (21 posts)

  1. Root
    Member
    Posted 9 years ago #

    1.3 Alpha 4 here. Am I right in saying that the new index file checks to see if there is a file called header php in the WP root directory and else it loads the default wp-header OR does it check in the theme directory for the alternative header php file ? ie its ABSPATH to what ?

  2. Root
    Member
    Posted 9 years ago #

    Yes but in the theme dir I can't get it to pick up header php. Am I doing something wrong? . And thank G you are here beel :)

  3. Root
    Member
    Posted 9 years ago #

    Well mine does not (not quite) :)

  4. Root
    Member
    Posted 9 years ago #

    In my install (latest nightly) the theme index takes footer php from the root directory - not the theme directory. It rather wrecks the theming switching idea at least temporarily. I do not know if its a file path typo or something or indeed how it is meant to work.

  5. Root
    Member
    Posted 9 years ago #

    So: Only one theme with alternative sub files can be installed at once. Have I got it right?

  6. Root
    Member
    Posted 9 years ago #

    Well that is fine and makes perfect sense. But I can not get my theme index file to pick up my theme footer file.

  7. Beel
    Member
    Posted 9 years ago #

    Hmm, make sure that index.php, wp-header, wp-footer, etc. in the root directory is the default install from WP. Also make sure footer.php, etc. is not in the root directory (they should be in your theme directory) and that you have include(footer.php), etc. in your index.php (the one in the theme directory).
    I think that should cover all the bases. Maybe not?

  8. Beel
    Member
    Posted 9 years ago #

    When wp-blog-header runs it comes across this:
    else if (is_home() &&
    file_exists("$wp_template_dir/index.php")) {
    $wp_did_template_redirect = true;
    include("$wp_template_dir/index.php");
    exit;
    thereby running your selected theme index file which has the include for your header sidebar and footer.

  9. Root
    Member
    Posted 9 years ago #

    Thanks I am trying all that now.

  10. Root
    Member
    Posted 9 years ago #

    I have that but my index file will not pick up either footer or wp-footer for example from its own theme dir.

  11. Root
    Member
    Posted 9 years ago #

    Fine. Fixed it. You need the full file path. No problem.

  12. Beel
    Member
    Posted 9 years ago #

    huh? full path? Hmmm, something else must be amiss as I don't have the fullpath. I'll have to explore further once I get back to my computer. Glad you got it, though.

  13. Root
    Member
    Posted 9 years ago #

    From /wp-content onwards.

  14. Ryan Boren
    WordPress Dev
    Posted 9 years ago #

    Includes are relative to the theme directory. In your theme's index.php, do this:
    <?php include('footer.php'); ?>
    footer.php should live in the theme directory next to index.php. That's all you need. Don't bother with wp-footer.php. That's for the default index, which you're not using since you're using a theme.

  15. Root
    Member
    Posted 9 years ago #

    It was the ABSPATH malarkey which confused me. Until I put in a long path it just would not run. I didnt know if it was a glitch or whether it should be like that ?

  16. Beel
    Member
    Posted 9 years ago #

    rboren: I'll have to take a look when I get back to my computer but I have the relative path to footer.php (and it works), however, if there is a footer.php in the root directory that gets included instead.

  17. Ryan Boren
    WordPress Dev
    Posted 9 years ago #

    Make sure your footer.php doesn't have any of that include_once(ABSPATH . '/footer.php') stuff in it. If you copied from wp-footer.php, you need to remove that stuff.
    It shouldn't be necessary to use ABSPATH anywhere in your theme. Even the require of wp-blog-header.php can be removed. Everything can and should be done relative to the theme directory.

  18. Root
    Member
    Posted 9 years ago #

    Thanks rboren. That is the key. Removing that bit from wp-footer and presumably the similar files. Thanks. We are rocking again now. Thanks to Beel too today. Nice work.

  19. Beel
    Member
    Posted 9 years ago #

    I bet that is it for me, too.

  20. Beel
    Member
    Posted 9 years ago #

    Hmm, no ABSPATH anywhere in my theme directory - must be something else and thus the hunt continues ;-)

  21. Anonymous
    Unregistered
    Posted 9 years ago #

    My root is
    \www\phproot\
    that contain the index.php,mainfile.php,header.php...
    I want to be able to have both the header and footer to another page that place in
    \www\phproot\MAIL\(my another page.php)
    In this case, what should I do?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.