Is it possible to Batch Create Posts? or Upload CSV to make posts?

[ad_1]

Hi I have an old website that i am restarting in WordPress

We have maybe 100 newsletters and stuff (PDFs, PPTx).

I’d like each of the newsletter or file to be a sperate news/blog Post, and it can just be displayed directly on that post.

Is there a way to create this in a batch process if i have a CSV like:

Title,FileName,DateCreated

hope my question made sense

Thanks

[ad_2]
3 Comments
  1. Assuming your CSV is in the format of title,date,content you could do something like this:

    if (($handle = fopen(‘./path-to-file.csv’, ‘r’)) !== FALSE) {
    while (($row = fgetcsv($handle, 0)) !== FALSE) {
    $new_post_data = [
    ‘post_title’ => $row[0],
    ‘post_date’ => $row[1],
    ‘post_content’ => $row[2],
    ];
    wp_insert_post($new_post_data);
    }
    fclose($handle);
    }

    You will of course need to tweak this code a little but it’s absolutely possible to do what you are asking.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer