Forums

require wp-config, wp-load etc blank screen issue (7 posts)

  1. paraleadogg
    Member
    Posted 2 years ago #

    Hi Guys,

    I am having a weird issue and have hunted round but as yet unable to find a solution. I am running a fresh install of wordpress 2.9.2 in a sub folder on my website i.e.

    mysite.com/blog

    Now - I would like to pull some latest posts into my website homepage which is outside of the WP install.

    After hunting round I found this could be achieved by simply requiring wp-load.php (giving me access to wordpresses functions etc)

    However upon doing this my sites home screen just gives a blank white screen (upon checking source code there is NO html at all)

    I then tried requiring_once - same issue.

    I then set - 'define('WP_USE_THEMES', false);' before calling require_once('blog/wp-load.php)

    same issue.

    I have also tried requiring the header files, and wp-config - but whenever i try and require ANY WP file i get the same blank screen.

    Just to test i created a test.php file within my blog directory and required that and it worked fine.

    So it just seems to be whenever i require a WP file.

    I have stepped through the code and the issue seems to be within the wp-settings file

    It tries to require a file called l10n.php and then we get the blank screen??

    Any ideas??

  2. Rev. Voodoo
    Volunteer Moderator
    Posted 2 years ago #

    yer on the right track:
    http://www.corvidworks.com/articles/wordpress-content-on-other-pages

    is a good write up on how to get WP posts into a homepage...works great for me.

    Make sure the require wp-load stuff is just before your </head> tag, and the rest of the stuff (the loop, for displaying your posts) is down in between the <body></body> tags somewhere.

    here's what I have in my head section:

    <?php
    // Include WordPress
    define('WP_USE_THEMES', false);
    require('../blog/wp-blog-header.php');
    query_posts('showposts=10');
    ?>
    </head>

    notice the ../ before blog. I'm not real good with this stuff, but the dots and slashes are used to back out of directories and enter new ones. you may need a single dot, or no dot.

    Also, gotta make sure your homepage is a .php and not .html, as this only works on .php pages (if your page is .html, you can just rename it)

    the part about requiring l10n.php, I'm not sure about....your code in your WP files looks goodf right? no hacks or anything?

  3. paraleadogg
    Member
    Posted 2 years ago #

    Yup

    The homepage is .php

    Also everything is done before any headers are called

    I know the path is correct because i have tried to require a test file (test.php) and that works fine.

    I don't even get as far as doing the loop - just simply including any WP file results in the white screen - before i have even done anything with it??

    It's weird

  4. Rev. Voodoo
    Volunteer Moderator
    Posted 2 years ago #

    Also everything is done before any headers are called

    I'm not sure what you mean by that?

    I originally didn't know how to bring wp into my site. I put that php code before the opening <head> tag and it wouldn't work. Then I put it after the opening <head> tag...and it would worki sometimes.... so finally I moved the php require business all the way down under my meta stuff, under my scripts, everything, until like I show above, it was right before the closing </head> tag. Its worked perfectly since

  5. paraleadogg
    Member
    Posted 2 years ago #

    Well - what I mean is everything is done before we send any content to the browser. Sometimes you can get an error saying that headers cant be set because they have already been sent.

    So i do all my server side processing before any headers are sent

    Just to test though i moved my require to just above my closing </head> tag

    Same deal

  6. paraleadogg
    Member
    Posted 2 years ago #

    I am guna try rolling back to wordpress 2.9.1 and see if that makes any difference.

  7. paraleadogg
    Member
    Posted 2 years ago #

    No difference lol

Topic Closed

This topic has been closed to new replies.

About this Topic