theduke01
Member
Posted 1 year ago #
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('http://www.dave-tyler.co.uk/wordpress/wp-load.php');
query_posts('showposts=1');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://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:
http://dave-tyler.co.uk/tylernew/wordpress_test.php
any ideas where i'm going wrong?
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);
theduke01
Member
Posted 1 year ago #
can you advise how i turn on error reporting? - relative path doesn't seem to be working either
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.
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.
New Nine
Member
Posted 1 year ago #
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');