First up, here is the code I am currently using.
PHP Code:
<?php
require( '../wp-load.php' );
// Load and parse the XML document
$rss = simplexml_load_file('http://feeds2.feedburner.com/bbc');
$title = $rss->channel->item->title;
//Check to see if post exists
function PostNotExist($title) {
global $wpdb;
if($wpdb->get_row ("SELECT post_title FROM wp_posts WHERE post_title = '" . $title . "'", 'ARRAY_A')) {
return false; } else { return true; }
}
// Loop to add each new item to Wordpress
foreach ($rss->channel->item as $item) {
if (PostNotExist($title)) {
global $user_ID;
$new_post = array(
'post_title' => $item->title,
'post_content' => $item->description,
'post_status' => 'publish',
'post_date' => date('Y-m-d H:i:s'),
'post_author' => $user_ID,
'post_type' => 'post',
'post_category' => array(0)
);
$post_id = wp_insert_post($new_post);
}}
?>
Quick explanation of what I am trying to achieve. I am trying to gather multiple RSS feeds and display them on a Wordpress blog.
The first problem I have is, in the foreach loop when the post title is new, it will only get the latest new post, and not the other new ones. Probably a simple fix here, I just cannot see it.
As I said I am trying to gather multiple RSS feeds, I know I will need an array to do this but not really sure about the rest.
Any help would be much appreciated.
Thanks
__________________
Free Flash designs and tutorials at Please login or register to view this content. Registration is FREE
Shorten your URL's with Please login or register to view this content. Registration is FREE
|