php - Insert RSS Feeds as WP posts -


how retrieve feed & insert using wp_insert_post(); interested if function can able pick 2 feeds each feed unique source.

if able code php easy loop through rss feed , insert data wordpress. create new post type (though of course can use default 'post' type). in example below using post type made called 'article'.

there many ways loop through rss feed, here use:

$rss = new domdocument(); $rss->load($rss_url);  // loop through each item in feed foreach ($rss->getelementsbytagname('item') $node) {   // code goes here    // example value   // define namespace   $ns = 'http://purl.org/rss/1.0/modules/content/';   $content = $node->getelementsbytagnamens($ns, 'encoded');   $content = $content->item(0)->nodevalue; } 

in loop through rss feed data , save variables, run following:

$new_article = array(     'post_title'    => $title,     'post_content'  => $content,     'post_excerpt'  => $description,     'post_type'     => 'article',     'post_date'     => date('y-m-d h:i:s',strtotime($date)),     'post_author'   => 1,     'post_status'   => 'publish' ); wp_insert_post( $new_article , true ); 

adjust needed fit needs.

hope helps, give lot more control plugin.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -