WordPress.org

Ready to get started?Download WordPress

Forums

Creating Batch Posts and a pseudo RSS feed by using Excel (16 posts)

  1. myagci
    Member
    Posted 6 years ago #

    Let's say you have a test list based on which you wish to batch create posts. I've not seen this covered anywhere else in the forums and I found it to be really neat so let me describe how useful it could be.

    Let's assume your text is comma separated and consists of three fields. Title, Description and Category.

    You can manipulate your data in many ways but I strongly recommend using Excel. Once you import your text into Excel, you now have three columns of information.

    Add a third column to form the XML item for each item.

    All you need to do is some text processing to enclose each information item within the proper XML tags.

    So you open with the Item tag, then enclose Title and Description and Category in their respective tags. I'm unable to show the Excel formula here but you you can see an example on my web page http://www.yagci.com/wordpress/.

    That's all you need to do per item. Now, of course, since we are within Excel, we can manipulate the text using Excel formulas. That's what I find to be so useful. Also, we can put actual HTML code in the Description field.

    All that's needed now is to put the resultant text records in a text file and give it the extension XML.

    Then you can import it into WordPress using the RSS import function.

    What I really enjoyed observing was that I did not have to form a full RSS feed. One XML record per line was sufficient for WordPress to import my data and create one post per record using the Title, Description and Category fields.

    Background

    Back in the ASP days, I had a database of items where I stored textual information and links to an audio database. The advantage of using database was that I could manipulate records in a systematic way. After I moved to WordPress, I had to create each item one by one. As I had something like 1000 items in the database it was not practical. With method I described above, I can now manipulate all my data on Excel, create a pseudo RSS feed and import that to WordPress. As long a I have a way to mass delete existing posts, a mass update is as simple as mass deleting and mass importing again.

  2. myagci
    Member
    Posted 6 years ago #

    Please note I'm now featuring the example in a new address.

  3. travelvice
    Member
    Posted 6 years ago #

    Hi there,

    Love what you've come up with here, and would love to adapt it.

    It is possible to import values for custom fields with this technique?

    What about multiple categories?

    Thanks for your thoughts

  4. tylercampbell
    Member
    Posted 6 years ago #

    Thanks for sharing this! Can't wait to experiment with this technique, although, like travelvice, I'll need to figure out how to get custom fields working in order for it to prove useful.

  5. travelvice
    Member
    Posted 6 years ago #

    I've figured this out.

    This is an example of a bare-bones XML file that you can import using the WORDPRESS option, which will give you access to all sorts of neat scheme options:

    <item>
    <title>Study Abroad in Venezuela</title>
    		<category><![CDATA[Venezuela]]></category>
    		<category><![CDATA[Studying Abroad]]></category>
    <content:encoded><![CDATA[<p>Information on studying abroad in Venezuela.</p>]]></content:encoded>
    <wp:postmeta>
    <wp:meta_key>description</wp:meta_key>
    <wp:meta_value>Studying Abroad in Venezuela - Where and how to study abroad in Venezuela</wp:meta_value>
    </wp:postmeta>
    </item>

    In this particular example, the item inserted is flagged as a DRAFT so that it can be reviewed, then published. It tosses in a title, 2 categories, body content, and a custom field called 'description'.

    The line breaks are required.

    Simply make Excel fill in the values for these, dump the cells into a text file, save with an .XML extension, and import. BOOM.

    I just did 244 entries in a few minutes -- amazing. No nasty SQL or table inserts.

    To see what other options you have, simply look at the results of an EXPORT from the MANAGE admin menu in notepad.

    WordPress is very forgiving, and you don't need ANYTHING except the above -- no XML header or footer information.

    Good luck!

    //craig, travelvice.com

  6. tylercampbell
    Member
    Posted 6 years ago #

    Just successfully imported my first two test posts with custom fields using Craig's method.

    Thanks again for the concept myagci and especially for the update, Craig.

    I'm using WordPress as a DAM, which means I rely heavily on custom fields containing filenames that, as a general rule, increase numerically. I can't even guess how much time this technique might save me down the road.

  7. travelvice
    Member
    Posted 6 years ago #

    You're welcome Tyler! I'm very excited myself.

    Another neat trick that I picked up before this was developed was that you can enter a comma separated string of category names on the post creation screen and hit the ADD button, and it will automatically check the categories that match those names -- it doesn't duplicate existing entries.

    Good luck to all

  8. Klark
    Member
    Posted 6 years ago #

    Oh shit..this looks promising for me.

    Can other fields like the date/time be added to this ? I have to import about a year's worth of data. They're already in excel. But i need them dated correctly.

    How can i include options of date and image links?

  9. micharo
    Member
    Posted 6 years ago #

    Hi,

    thanks for the code and idea above!

    One more question:
    I use the following xml and it works great but the custom field is not added to the post.
    Any ideas?

    <item>
    <pubDate>15 February 2008 00:00:00 +0001</pubDate>
    <title>rin</title>
    <description>easy</description>
    <category>Adrian</category>
    <category>rings</category>
    <postmeta>
    <meta_key>observer</meta_key>
    <meta_value>m</meta_value>
    </postmeta><
    /item>
  10. flick
    Member
    Posted 6 years ago #

    @micharo: I think for the tags you're missing <wp:>
    so for instance, it should be
    <wp:postmeta>
    rather than
    <postmeta>

  11. kamu
    Member
    Posted 5 years ago #

    <item>
    <pubDate>15 February 2008 00:00:00 +0001</pubDate>
    <title>rin</title>
    <description>easy</description>
    <category>Adrian</category>
    <category>rings</category>
    <wp:postmeta>
    <wp:meta_key>observer</wp:meta_key>
    <wp:meta_value>m</wp:meta_value>
    </wp:postmeta><
    /item>

    its not working with custom field.
    i used the rc:custom_field_gui plugin for the custom field.
    pls someone help me.
    thanks.

  12. sebastienpage
    Member
    Posted 5 years ago #

    Nice!

    I have one problem though. I am trying to import posts into sub-categories and I am having issues....

    I can import to a category without any problem but I can't figure out the import to a subcategory.

    I unsuccessfully tried the following:

    <wp:category><wp:category_parent>Yoga Classes</wp:category_parent><wp:cat_name><![CDATA[Test Yoga Classes - TE]]></wp:cat_name></wp:category>

    It creates the post and it creates the subcategory but it won't put the post in this subcategory. I just puts the post in "uncategorized".

    Your help on this would be greatly appreciated.

    Thanks

  13. Klark
    Member
    Posted 5 years ago #

    Import into Parent Category > Then Make Parent category a sub category

  14. supsupolo
    Member
    Posted 5 years ago #

    maybe this is a very stupid question but how do you export the data from excel with the replaced values in it , when I paste the formula formula from myagci in excel the values don't change, either the formula is not working or I am doing something wrong

  15. mfshearer72
    Member
    Posted 5 years ago #

    How can I set this up so it imports as a page, not a post? I've successfully added 300 posts in one import, but I need to do it for pages AND set a custom template at the time of import.

    Thanks!

    Michael

  16. mfshearer72
    Member
    Posted 5 years ago #

    I tried this:

    <item><title>Page Name</title><wp:post_type>page</wp:post_type><wp:postmeta>
    <wp:meta_key>_wp_page_template</wp:meta_key>
    <wp:meta_value>support.php</wp:meta_value>
    </wp:postmeta>
    </item>

    But it still got imported as a Post.

Topic Closed

This topic has been closed to new replies.

About this Topic