• Hi,

    I am trying to load wordpress content from my site into an external web page, without success. I am using the following code:

    <?php
    
    // Include WordPress
    
    define('WP_USE_THEMES', false);
    
    require('https://www.dave-tyler.co.uk/wordpress/wp-load.php');
    
    query_posts('showposts=1');
    
    ?>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="https://www.w3.org/1999/xhtml">
    
    <head>
    
    <meta http-equiv="Content-Type" content="text/html; />
    
    <title>Untitled Document</title>
    
    </head>
    
    <body>
    
    <?php while (have_posts()): the_post(); ?>
    
    <h2><?php the_title(); ?></h2>
    
    <?php the_content(); ?>
    
    <p><a href="<?php the_permalink(); ?>">Read more...</a></p>
    
    <?php endwhile; ?>
    
    </body>
    
    </html>

    link to the page on my server:

    https://dave-tyler.co.uk/tylernew/wordpress_test.php

    any ideas where i’m going wrong?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator Helen Hou-Sandi

    (@helen)

    Core Lead Developer and 4.0, 4.7, and 5.6 Release Lead

    Is it possible for you to turn on error reporting so you can see what’s going wrong? My guess is that require() does not want to take a full URL. Try using a relative local path instead, e.g. require('../wordpress/wp-load.php);

    Thread Starter theduke01

    (@theduke01)

    can you advise how i turn on error reporting? – relative path doesn’t seem to be working either

    Moderator Helen Hou-Sandi

    (@helen)

    Core Lead Developer and 4.0, 4.7, and 5.6 Release Lead

    Sure, in your wp-config.php file, add the line define('WP_DEBUG', true);. If you already have one that defines WP_DEBUG as false, just edit that line instead. Be sure this line comes above where it says to stop editing and happy blogging (something along those lines). This should turn on error reporting and will give you more information about what’s going wrong.

    Moderator Helen Hou-Sandi

    (@helen)

    Core Lead Developer and 4.0, 4.7, and 5.6 Release Lead

    ACTUALLY, I just remembered you’re doing something outside of WordPress. If this doesn’t work, try error_reporting(E_ALL); at the top of your custom file instead. There are some other methods of turning on error reporting globally, so if those don’t work, there are some other options.

    The require function needs a relative path on your server. In your case, it looks like WordPress is installed in a subfolder (wordpress) of your main document root. Try this:

    require_once($_SERVER['DOCUMENT_ROOT'].'/wordpress/wp-load.php');

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘wp-load not working’ is closed to new replies.