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.

I have installed a WP on website A and I want the last post's links in site B. I haven't in site B any WP and I want to get the link of last post from website A. so I can't use WP API like WP_Query and so on..

Is there possible I do this with remote connection to MuSql and get the last post link?

How do this?

share|improve this question

2 Answers 2

Assuming each site is WP, they'll both have RSS feeds. You're better off just to fetch the RSS feed and get the latest post link from that.

WP even has some built in support RSS parsing!

<?php
/**
 * An example of how to use fetch feed
 *
 * @uses    fetch_feed
 * @return  bool|string False on failure, the permalink on success
 */
function wpse60754_fetch_feed($feed_url)
{
    $feed = fetch_feed($feed_url);

    if(is_wp_error($feed))
        return false;

    $items = $feed->get_items(0, 1);

    if(count($items))
        return $items[0]->get_permalink();
    else
        return false;
}
share|improve this answer

I think this is what you might be looking for.

http://net.tutsplus.com/articles/news/how-to-read-an-rss-feed-with-php-screencast/

Basically on the NON-WP site create a function that parses an RSS feed via file_get_contents() and SimpleXmlElement() combined to grab the titles.

Instead of a foreach loop though use do $x[0]->whatever like this:

<?php  

function getFeed($feed_url) {  

    $content = file_get_contents($feed_url);  
    $x = new SimpleXmlElement($content);  

    $entry = $x[0]->channel->item

    echo "<a href='$entry->link' title='$entry->title'>" . $entry->title . "</a>";  

}  
?>  
share|improve this answer

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.