Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8647991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:12:32+00:00 2026-06-12T13:12:32+00:00

Alright here is the thing, I have this site that was once wordpress but

  • 0

Alright here is the thing, I have this site that was once wordpress but have been converted into 70+ static pages, the admin is deleted and the whole site is static(which means every page is in index.html), I want to create a script that makes an xml so that I will just have to import it in the new wordpress install.

So far, I am able to create an XML but it only imports one post.

The data source is the URL of a page and I use jquery $get to filter only to gather the post of a given archive.

//html
<input type="text" class="full_path">
<input type="button" value="Get Data" class="getdata">

//script

$('.getdata').click(function(){
            $.get($('.full_path').val(), function(data) {
              post = $(data).find('div [style*="width:530px;"]');
              $('.result').html(post.html());

            });
        });//get Data

Through AJAX I send the cleaned data into a php below that creates the XML:

$file = 'newpost.xml';
$post_data = $_REQUEST['post_data'];
// Open the file to get existing content
$current = file_get_contents($file);
// Append a new post to the file
$catStr = '';
if(isset($post_data['categories']) && count($post_data['categories']) > 0){
    foreach($post_data['categories'] as $category) {
        $catStr .= '<category domain="category" nicename="'.$category.'"><![CDATA['.$category.']]></category>';
    }   
}
$tagStr = '';
if(isset($post_data['tags']) && count($post_data['tags']) > 0){
    //populate post_tag like the above
}
$post_name = str_replace(' ','-',$post_data["title"]);
$post_name = str_replace(array('"','/',':','.',',','[',']','“','”'),'',strtolower($post_name));

$post_date = '2011-4-0'.rand(1, 29).''.rand(1, 12).':'.rand(1, 59).':'.rand(1, 59);
$pubTime = rand(1, 12).':'.rand(1, 59).':'.rand(1, 59).' +0000';

$post = '
    <item>
        <title>'.$post_data["title"].'</title>
        <link>'.$post_data["link"].'</link>
        <pubDate>'.$post_data["date"].' '.$pubTime.'</pubDate>
        <dc:creator>admin</dc:creator>
        <guid isPermaLink="false">http://localhost/saunders/?p=1</guid>
        <description></description>
        <content:encoded><![CDATA['.$post_data["content"].']]></content:encoded>
        <excerpt:encoded><![CDATA[]]></excerpt:encoded>
        <wp:post_id>1</wp:post_id>
        <wp:post_date>'.$post_date.'</wp:post_date>
        <wp:post_date_gmt>'.$post_date.'</wp:post_date_gmt>
        <wp:comment_status>open</wp:comment_status>
        <wp:ping_status>open</wp:ping_status>
        <wp:post_name>'.$post_name.'</wp:post_name>
        <wp:status>publish</wp:status>
        <wp:post_parent>0</wp:post_parent>
        <wp:menu_order>0</wp:menu_order>
        <wp:post_type>post</wp:post_type>
        <wp:post_password></wp:post_password>
        <wp:is_sticky>0</wp:is_sticky>
        '.$catStr.'
        '.$tagStr.'
        <wp:postmeta>
            <wp:meta_key>_edit_last</wp:meta_key>
            <wp:meta_value><![CDATA[1]]></wp:meta_value>
        </wp:postmeta>
    </item>
';



// Write the contents back to the file with the appended post
file_put_contents($file, $current.$post);

After being appended I add the code below to complete the xml rss tag

</channel>
</rss>

If I look and compare the xml file of one that is exported from a wordpress site, I see little difference. Please HELP!!

here is a sample of a generated xml:

<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0"
    xmlns:excerpt="http://wordpress.org/export/1.2/excerpt/"
    xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:wfw="http://wellformedweb.org/CommentAPI/"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:wp="http://wordpress.org/export/1.2/"
>
<channel>
    <title>lols why</title>
    <link>http://localhost/lols</link>
    <description>Just another WordPress site</description>
    <pubDate>Wed, 03 Oct 2012 04:24:04 +0000</pubDate>
    <language>en-US</language>
    <wp:wxr_version>1.2</wp:wxr_version>
    <wp:base_site_url>http://localhost/lols</wp:base_site_url>
    <wp:base_blog_url>http://localhost/lols</wp:base_blog_url>

    <wp:author><wp:author_id>1</wp:author_id><wp:author_login>adedoy</wp:author_login><wp:author_email>wazzup@gmail.com</wp:author_email><wp:author_display_name><![CDATA[adedoy]]></wp:author_display_name><wp:author_first_name><![CDATA[]]></wp:author_first_name><wp:author_last_name><![CDATA[]]></wp:author_last_name></wp:author>


    <generator>http://wordpress.org/?v=3.4.1</generator>

    <item>
        <title>Sample lift?</title>
        <link>../../breast-lift/delaware-breast-surgery-do-i-need-a-breast-lift/</link>
        <pubDate>Wed, 03 Oct 2012 9:29:16 +0000</pubDate>
        <dc:creator>admin</dc:creator>
        <guid isPermaLink="false">http://localhost/lols/?p=1</guid>
        <description></description>
        <content:encoded><![CDATA[<p>sample</p>]]></content:encoded>
        <excerpt:encoded><![CDATA[]]></excerpt:encoded>
        <wp:post_id>1</wp:post_id>
        <wp:post_date>2011-4-0132:45:4</wp:post_date>
        <wp:post_date_gmt>2011-4-0132:45:4</wp:post_date_gmt>
        <wp:comment_status>open</wp:comment_status>
        <wp:ping_status>open</wp:ping_status>
        <wp:post_name>sample-lift?</wp:post_name>
        <wp:status>publish</wp:status>
        <wp:post_parent>0</wp:post_parent>
        <wp:menu_order>0</wp:menu_order>
        <wp:post_type>post</wp:post_type>
        <wp:post_password></wp:post_password>
        <wp:is_sticky>0</wp:is_sticky>
        <category domain="category" nicename="Sample Lift"><![CDATA[Sample Lift]]></category><category domain="category" nicename="Sample Procedures"><![CDATA[Yeah Procedures]]></category>
        <category domain="post_tag" nicename="delaware"><![CDATA[delaware]]></category>
        <wp:postmeta>
            <wp:meta_key>_edit_last</wp:meta_key>
            <wp:meta_value><![CDATA[1]]></wp:meta_value>
        </wp:postmeta>
    </item>
    <item>
        <title>lalalalalala</title>
        <link>../../administrative-tips-for-surgery/delaware-cosmetic-surgery-a-better-experience/</link>
        <pubDate>Wed, 03 Oct 2012 3:20:43 +0000</pubDate>
        <dc:creator>admin</dc:creator>
        <guid isPermaLink="false">http://localhost/lols/?p=1</guid>
        <description></description>
        <content:encoded><![CDATA[
                lalalalalala
            ]]></content:encoded>
        <excerpt:encoded><![CDATA[]]></excerpt:encoded>
        <wp:post_id>1</wp:post_id>
        <wp:post_date>2011-4-0124:39:30</wp:post_date>
        <wp:post_date_gmt>2011-4-0124:39:30</wp:post_date_gmt>
        <wp:comment_status>open</wp:comment_status>
        <wp:ping_status>open</wp:ping_status>
        <wp:post_name>lalalalalala</wp:post_name>
        <wp:status>publish</wp:status>
        <wp:post_parent>0</wp:post_parent>
        <wp:menu_order>0</wp:menu_order>
        <wp:post_type>post</wp:post_type>
        <wp:post_password></wp:post_password>
        <wp:is_sticky>0</wp:is_sticky>
        <category domain="category" nicename="lalalalalala"><![CDATA[lalalalalala]]></category>
        <category domain="post_tag" nicename="oink"><![CDATA[oink]]></category>
        <wp:postmeta>
            <wp:meta_key>_edit_last</wp:meta_key>
            <wp:meta_value><![CDATA[1]]></wp:meta_value>
        </wp:postmeta>
    </item>
</channel>
</rss>

Please tell me what am I missing….

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T13:12:33+00:00Added an answer on June 12, 2026 at 1:12 pm

    Okay, to rehash and make sure I understand you, this is an attempt to return to wordpress from your static files.

    To do this, there are really three major methods outlined on the WP codex about importing from an RSS feed, (X)HTML, and static pages. This being said, one of the easiest methods if you have well-formed HTML, which it would appear you do from your JQuery search string, is to use the HTML Import 2 plugin, referenced in the codex. It provides you a number of options to do this from a directory, url, and to specify the search parameters from the admin screens of your new installation.

    Should this not work for you or you really want to convert all the pages to XML for import, because you’re already using PHP to generate the XML, I’d strongly recommend using the PHP DOM library to open, parse, extract, and write the data from your static files. This will save you from the time involved in browsing through the entire site to generate the XML and it will produce an entire XML file of all your pages in one fell swoop.

    Either way, I would recommend using a plain RSS file and not trying to re-create WordPress’ custom format because, done properly, it has a lot of database references (maps IDs and so forth) for all the content types. Since it doesn’t seem you need it, try just making a normal RSS file that has the bare minimum of what you need, and you can edit those posts to re-assign authors, etc. if necessary after you import that using the codex directions for importing from an RSS feed. It will be far easier.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a model with some inheritance worked into it, but here's the thing,
Alright, so I'm making a Facebook-style chat. But that doesn't really matter. See here:
Alright, hard to phrase an exact title for this question, but here goes... I
Alright so this is a bizarre cross platform thing that I'm experiencing with text
Alright here's the situation, I have an application written in the Zend_Framework, that is
Alright, I presented this question on the MSDN forums but have yet to receive
Alright, admittedly there are a lot of words here, but this is a problem
Alright i have been searching for days but there is no example of what
This question has been asked here in one form or another but not quite
Alright so I'm trying to get captcha to work here and I have this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.