Categorized | PHP, Snippets

Quick and Dirty CSV to RSS/XML for WordPress Import…

After running, you can view the source and save the output to an XML file that you can import into WP. Nothing fancy, but thought it might help one or two ppl… It is set-up to date the posts every 12 hours, although this is easily changed…

<?php
function get_csv($filename, $delim=',')
{
   $row = 0;
   $dump = array();

   $f = fopen ($filename,"r");
   $size = filesize($filename)+1;
   while ($data = fgetcsv($f, $size, $delim)) {
       $dump[$row] = $data;
       $row++;
   }
   fclose ($f);

   return $dump;
}

$myfile = "123.csv";
$xxx=0;
$mywritefile = "";

$test = get_csv($myfile);

foreach ($test as $mthis) {
$xxx++;
$hourcount = ($xxx * 12);
$mincount = (12 * $xxx);
$futuredate = mktime(date("h")+$hourcount,date("i")+$mincount,date("s")+$mincount,date("m"),date("d"),date("Y"));

$mypubdate = date("D, d M Y h:i:s A",$futuredate);

$mywritefile .= "<item>\n";
$mywritefile .= "<title>".$mthis[0]."</title>\n";
$mywritefile .= "<category>Your Category Tag</category>\n";
$mywritefile .= "<content:encoded>".$mthis[1]."<br />".$mthis[2]."<br />".$mthis[3]."<br />".$mthis[4]."</content:encoded>\n";
$mywritefile .= "<pubDate>".$mypubdate."</pubDate>\n";
$mywritefile .= "</item>\n\n\n";

}

echo $mywritefile;

?>
My Kind of Woman

My Kind of Woman

Tags: , , , , , , , , , , , , , ,

No related posts found

This post was written by:

kpaul - who has written 808 posts on Webmaster Chronic Blog.

poet, publisher

Contact the author

2 Responses to “Quick and Dirty CSV to RSS/XML for WordPress Import…”

  1. ClarkLogan says:

    Time for volleyball. Should be interesting. #sportsisuckat

  2. deiana101 says:

    I love it in the film when the little fat muse is going crazy with her horn…

Trackbacks/Pingbacks


Leave a Reply

Webmaster Chronic

Tha Goodiez has added a photo to the pool: