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've made a simple code here to fetch and insert the last news from a feed Rss:

<?php // Get RSS Feed(s)

$uri = 'http://rss.cnn.com/rss/edition.rss';
$feed = fetch_feed($uri);

foreach ($feed->get_items() as $item){

$titlepost = $item->get_title();
$content = $item->get_content();
$description = $item->get_description();

$my_post = array();
$my_post['post_title'] = "$titlepost";
$my_post['post_name'] = "$titlepost";
$my_post['post_content'] = "$content";
$my_post['post_status'] = 'publish';
$my_post['tags_input'] = $thetags;
$my_post['post_author'] = 1;
$my_post['post_type'] = 'post';
$my_post['post_excerpt'] =  "$description";

$post_id = wp_insert_post($my_post);



I would want check the feed regularly and insert new posts only if the post does not exist already.

Should I then insert a rule that first checks if the title exists and, in this case, declare not to insert anything, else, have regular wp_insert_post.

Can we help Me ?

share|improve this question
Yes, you should –  AlxVallejo Jul 26 '12 at 16:23
add comment

Your Answer


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

Browse other questions tagged or ask your own question.