• Hello I’m designing a theme but having some trouble..

    I have an index.php and I include this line at very start

    <?php define('WP_USE_THEMES', true); require('./wp-blog-header.php'); ?>

    The WP_USE_THEMES is self explanatory and the wp-blog-header I guess is
    to start up wordpress.

    Anyways I put a link on the page which points to articles.php and I include this line inside articles.php but I get this error.

    Warning: require(./wp-blog-header.php) [function.require]: failed to open stream: No such file or directory in C:\xampp\htdocs\wp-content\themes\Tutorial\articles.php  on line 1
    
    Fatal error: require() [function.require]: Failed opening required './wp-blog-header.php' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\wp-content\themes\Tutorial\articles.php on line 1

    I’m not sure why it works in index.php and not in articles.php, it looks like it cannot find ./wp-blog-header.php (im not sure where that is btw, but index.php seems to find it okay)

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter Yeowza

    (@yeowza)

    ahh i see, wp-blog-header.php is located on root

    I guess ./ points to root then, why would it load with index.php and not with articles.php though? the are both in same directory

    Thread Starter Yeowza

    (@yeowza)

    I moved wp-blog-header.php into wp-content/themes/ThemeName/ and it works..

    So this means that the problem is because ./ is referring to
    wp-content/themes/ThemeName

    Is there way for me to specify root when I do not know the URL?

    ex: https://www.website.com/wp-blog-header.php

    Thread Starter Yeowza

    (@yeowza)

    ok I think I fix it..

    what I did was just go some directory’s up relativly

    <?php require('./../../../wp-blog-header.php'); >

    This just goes 3 directories up, where wp-blog-header.php is located.. gonna keep testing to see if there are any problems.

    I’m planning on distributing this theme so I guess it will keep working as long as the user does not move files around

    still not sure why <?php define('WP_USE_THEMES', true); require('./wp-blog-header.php'); ?> works with index.php though

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    Your theme should not be including WordPress files like that at all.

    Look at some existing themes for examples.

    Basically, you’re doing it wrong.

    Thread Starter Yeowza

    (@yeowza)

    It works pretty good though Otto42. I am making a theme but it is more of a website with wordpress integrated into it. (But distributed like a theme)

    Once I finish it i’ll show it off to ya

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘require(‘./wp-blog-header.php’);’ is closed to new replies.