0

What I mean is...

I'm trying to Import an Excel file with 1000s of data into Wordpress. That's the easy part, there are plugins that import excel data.

I also want for each "data" to create a post with certain fields already at default, automatically some way, cause we're talking about 1000s of entries not mere 100s...

For example... One entry would look like this:

   Title            Author           Editor            ISBN

(Book title)    (Book Author)    (Book Editor)    (16 digit ISBN)

And so far I've found a simple way to add something automatically every time I create a new post using the functions.php file

add_filter( 'default_content', 'my_editor_content' );
function my_editor_content( $content ) {
$content = " (my-content-here) ";
return $content;
}

which adds (my-content-here) into every post I make.

What i want to do though, if it's possible, cause again there are many entries, is if for each post I create I can get the title/author/editor/isbn automatically, the same way like above, from data I've imported from the excel file... and make them look like this:

                       (Title in bold)



                Author(s):

                Editor:

                ISBN: 


                Back cover presentation:

And the thing that I'll have to do is correct any mistakes each post may have and/or add more things that need to be added like an image on top of the title...

Right now I'm using the Custom Post Type UI for the custom post types like Fantasy books, or Science books, etc. So that each Category of books is it's own post type.

Edit: Also do I need Custom Fields to achieve what I'm suggesting? like the Advanced Custom Fields plugin?

0

Sounds like a single "book" post type would be most appropriate. You could then add custom postmeta, which does not require Advanced Custom Fields. I would create the post type and custom fields first, test them out to make sure they're saving appropriately to the database. Then, you can do a foreach loop for each line in your CSV, and use wp_insert_post which has a meta_input parameter where you can add all the corresponding custom fields (postmeta).

| improve this answer | |
  • custom postmeta? Also... I lost you here " Then, you can do a foreach loop for each line in your CSV, and use wp_insert_post which has a meta_input parameter where you can add all the corresponding custom fields (postmeta). " how am I gonna do a for each loop for a CSV? .... I'm gonna try and test the custom postmeta you said :D ... Thanks a lot for your suggestion! – Too Many Questions Mar 15 '17 at 7:31
  • Look into stackoverflow.com/questions/1269562/… - read the CSV into an array, then you can do foreach. Lots of work to do here but you'll learn a ton about custom post types, custom postmeta, and CSV manipulation. :) – WebElaine Mar 16 '17 at 15:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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