Page is a not externally linkable
- Code, Content, and Presentation
-- WordPress
---- How to link to recent posts from main website outside wp


abhainn - 10:49 am on Oct 15, 2012 (gmt 0)


Hi,

I'm trying to display a list of the most recent wordpress posts on my main website. I can find a php code to do this, but it assumes the wp files are at the document root, which they are not - they are in a database on the same server, but not under the same document root. I don't know how to specify the correct path, I don't even know if it is possible.

Could anyone help, please?

This is the code


<ul>
<?php require($_SERVER['DOCUMENT_ROOT'] . '/document-root/etc/etc/wp-load.php'); query_posts('showposts=3'); if (have_posts()) : while (have_posts()) : the_post(); ?>
<li> <h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
<span>Posted on <?php the_time('l jS F, Y') ?></span><br />
<?php the_excerpt(); ?> </li>
<?php endwhile; else: echo "no posts"; endif; ?>
<?php wp_reset_query(); ?>
</ul>


Document root: /webspace/httpdocs/mywebsite/
Database: /webspace/siteapplications/0000/
File I need the path to: /webspace/siteapplications/0000/htdocs/wp-load.php

After a lot of searching it looks to me that I might need to specify the path in the form of /var/www/ but I still don't know how to change the
<?php require($_SERVER['DOCUMENT_ROOT']

Am I going the right direction, or completely lost, please?

Thanks a million...

T.


Thread source:: http://www.webmasterworld.com/wordpress/4508113.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com