Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

What i'm trying to achieve is bringing a loop from one WP site into another WP Site.

I used this method to get the loop into an external php file (which all works fine, the results show)

<?php
define('WP_USE_THEMES', false);
require('path_on_server/wp-blog-header.php');
query_posts('showposts=5');
?>

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <li>
        <a href="<?php the_permalink() ?>"><?php the_title(); ?>" /></a>
    </li>
<?php endwhile; endif;  ?>

I then try and include the file in my sidebar using a simple php include call but the results don't show.... I imagine this is because of some sort of confliction between my WP & the other sites WP.

Any help on achieving this?

Thanks

share|improve this question
    
Why not pull in the other site's feed? –  t31os Apr 18 '11 at 11:27
1  
add comment

2 Answers

up vote 0 down vote accepted

If you want to grab info right off the page you should use one of these options if you don't want a plugin, the content can be returned and parsed as xml, rss, json or just html/text. This is the proper way to do this.

WordPress HTTP API: http://codex.wordpress.org/HTTP_API or
fetch_feed() ( for rss only).

ps. On side note I usually use simplexml instead of the built in rss wp stuff as it has way more functionality along with the HTTP API.

Also an alternative, though more troublesome way is to connect to the other database.

share|improve this answer
add comment

Use the FeedWordPress plugin instead.

share|improve this answer
    
This seems a little bulky for what i'm after. Also some of the loops will have things like star ratings & pictures in them so i need to be able to customise the loop. Thanks tho –  Blackbird Apr 18 '11 at 11:02
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.