Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm creating a website for a publisher that contains +- 1.500 registered and these books have its prices rearranged time to time, obviously it would be a hard time to manually upload each one of them.

For these books I must have some custom fields, like author, pages, format, cover(image), first chapter, authors page (internal page of the author), and some others that I can put some files for download.

So since you guys know the main function of the site, I have some questions:

Which are the the best way of creating these functions? (I've tried some e-commerce/store themes but the next question ruined it)

I will have to upload the prices of the these books time to time, so there is a way of importing just the information that is contained in the field price all in once? I mean like importing a xml, a sql direct in the data base that will upload/overwrite only this field for all the books, since they have different prices? (I know I will have to specify the id or some other field of each one of the books for the data base understand which posts it must change)

I know that is complicated (at least for me) but I've trying to figure out how I'm going to do all of these programming and yet I don't know.

If anyone could help me, that would be amazing!

Thanks!

share|improve this question

2 Answers 2

So if I understood correctly, you're make a site for a client, and already have a list of "books" you want to import.

My suggestions :

  • Create a custom post type for your books

    I think it's the best approach, and it allows you to add any custom fields you want as meta fields.

  • Look up wp_insert_post

    It allows you to programmatically insert posts, so you can loop your current data and for each book, insert a new post in you books CPT.

  • Look up add_post_meta / update_post_meta

    Allows you to set your CPT's custom meta fields with w/e info you need attached to a book

  • Curl may also be helpful if you have to grab external files.

share|improve this answer
    
Thanks Shane, indeed. Actually I have already started to custom the theme, and I've created the custom post type. For me that's the easy part, the real problem is to insert all these data and upload it after. Now, with your answer I see I'm in the right path, but I wanted to know opinions about how create and manage it. I'm going to see everything you mentioned and try to solve my problem. Once again, thanks very much. –  Hian De Mello Battiston Jan 20 '12 at 19:29

There are some solutions for XML database imports out there but it's a better idea to create a custom script/plugin pertaining to your exact needs, considering this isn't just for one import but for updates as well.

The fist part to figure out is how is the data formatted and is it friendly to import? (XML/SQL/JSON/.. format?)

The second part is to figure out if you want to use native WordPress database tables, for example custom post fields, or instead use a custom table you create yourself with the WPDB class ( or maybe with the pods plugin).

If the updates you have to make are frequent and complex you will need to build this into the plugin/script, otherwise you could simply login and change the fields manually.

There is no specific answer to your question, basically you need to write ( or possibly find) a plugin/script that can parse/read XML to update the database entries. I would have a look at some of the current XML import scripts to see how this is done.

share|improve this answer
    
Thanks Wyck, really helpful! Actually, I don't know how the data is because the client haven't sent yet, but that's not a problem because we decided that I will tell them how to format the data and after sent the data to me to upload. Unfortunately I don't have the knowledge to create a plugin so I'll have to find one or try to put together some functions! I'm going to take a look in XML import for sure! Once again, thanks very much. –  Hian De Mello Battiston Jan 20 '12 at 19:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.