July 24, 2010 | In: computer engineering
Transfering content from Joomla to WordPress
Recently I had to help with a site switch from the Joomla! CMS to WordPress. There is an tool published in the Worpdress website which can be found here:
http://codex.wordpress.org/Importing_Content#Joomla
http://www.onestopjoomla.com/extensions/migrate/joomla-to-wordpress-import-wizard/
but it doesn’t work for the new versions of these CMSes. There is an error that has to do with WordPress post_category field, which being obsolete for many versions,now has been removed. This can be easily tackled by altering the INSERT INTO query in the index.php a bit like this:
$query = “INSERT INTO “.$wptblprefix.”posts (id, post_author, post_title, post_content, post_date, post_modified, post_name) VALUES (”, ‘$ID5′, ‘{$import[1][$j]}’, ‘{$import[2][$j]}’, ‘{$import[3][$j]}’, ‘{$import[4][$j]}’, ‘$post_name’)”;
I.e. you have to remove the “,post_category” and the corresponding VALUE. This must be done in 2 points at the code, find them with a search.
You may also easily substitute the “default” author ID in WordPress with the actual author ID from Joomla! dynamically. You can do this like that:
- alter the SELECT from Joomla! query by adding “created_by”:
/* Performing SQL query */
$query = “SELECT id, title, introtext, `fulltext`, created, modified, created_by FROM “.$joomlatblprefix.”content WHERE `sectionid` = ‘$section’”
- load the VALUE into the import ARRAY:
while ($row = mysql_fetch_assoc($result)) {
$import[0][$i] = mysql_escape_string($row["id"]);
$import[1][$i] = mysql_escape_string($row["title"]);
$import[2][$i] = mysql_escape_string($row["introtext"].”<br /><!–more–><br />”.$row["fulltext"]);
$import[3][$i] = mysql_escape_string($row["created"]);
$import[4][$i] = mysql_escape_string($row["modified"]);
$import[5][$i] = mysql_escape_string($row["created_by"]);$i++;
}
- in the while loop, replace the following code:
$j = 0;
while ($j < $i) {/*select author */
//62,63,67,69 are the author IDs in the Joomla! database table jos_users and author1,…,author4 are the corresponding usernames in the WordPress databse
if($import[5][$j]==”62″) $authorusername=”author1″;
if($import[5][$j]==”63″) $authorusername=”author2“;
if($import[5][$j]==”67″) $authorusername=”author3“;
if($import[5][$j]==”69″) $authorusername=”author4“;/* Create an acceptable WP post_name */
$post_name = sanitize_title_with_dashes($import[1][$j]);
These changes helped me transfer my content (around 300 articles) from Joomla 1.5.16 to WordPress 3



Σχολια επισκεπτων