Hi Everyone,
I need to import a Wordress Blog with around 1000 posts and I'm using component Jconverter that can be found here:
http://ow.ly/WbuL , this component works only in half, I explain. It does import posts and categories, I'm not a developer but I went into the code and fixed the posts import, they were imported without alias so it's fixed now, but when posts are imported they lose the category they belong to.
I took a look at the database structure of wordpress, that can be found here:
http://codex.wordpress.org/File:WP_27_dbsERD.png , to try to find a way link the posts to their category while importing but with no success, I don't know either Mysql, at least not enough to make a query that would keep this relationship between the post and its category.
Here is the code used to import the posts (from jconverter component):
function migrateWpPosts() {
$query = "SELECT * FROM " . $this->_config['prefix'] . "posts WHERE post_status = 'publish' AND post_type = 'post'";
//echo $query;
$this->_externalDB->setQuery( $query );
$posts = $this->_externalDB->loadObjectList();
//print_r($posts);
//$ret = $this->insertObjectList('#__users', $users);
$db =& JFactory::getDBO();
$query = "SELECT id FROM #__sections WHERE title = 'WordPress'";
$db->setQuery( $query );
$sid = $db->loadResult();
foreach ($posts as $post)
{
$pTitle = mysql_real_escape_string($post->post_title);
$pName = mysql_real_escape_string($post->post_name);
$pIntro = mysql_real_escape_string($post->post_excerpt);
$pContent = mysql_real_escape_string($post->post_content);
$pDate = mysql_real_escape_string($post->post_date);
$query = "INSERT INTO #__content (title, alias, introtext, #__content.fulltext, created, created_by, state, sectionid) VALUES ('$pTitle', '$pName', '$pIntro', '$pContent', '$pDate', 62, 1, '$sid')";
//echo $query;
$db->setQuery( $query );
$ret = $db->query();
//echo $db->errorMsg();
}
return $ret;
}
Does anyone have a suggestion on how I could achieve this query?
Thank you very much for your help.
You need to be a member of All Together, As A Whole to add comments!
Join All Together, As A Whole