• Hello,
    I’m trying to upload a lot of information from a csv file & to have wordpress create a post from each row, which contain the title, description, etc.

    The problem that I have is that all posts are assigned to the default category (the “unassigned” one when you create wordpress).

    I’m guessing that this is because the php I’m trying to use below uses “post_category” which is no longer supported, so my question is what do I replace this “post_category” line with in order to make it work – I can’t get my head around the new taxonomy structure.

    Can anyone help please???

    The full code:

    moderate code pasted at https://wordpress.pastebin.ca/1299010

    Many Thanks in advance!

Viewing 8 replies - 1 through 8 (of 8 total)
  • post_category needs to be an array, so something like this should work:

    $my_post['post_category'] = array(prep($row['category']));

    Thread Starter daveshu1

    (@daveshu1)

    filosofo – you are a genius!!

    Thankyou, thankyou, thankyou for your input, it now works beautifully!!!

    I can’t thankyou enough, but I’ll just say thank you once again just to make sure I’m at least trying!!

    Cheers!!

    Thread Starter daveshu1

    (@daveshu1)

    Hmmmm….

    although there is one other small thing ??

    I decided to try & make it work from inside the admin panel as a plugin rather than from a url, and I’m a bit stuck on this.

    I’ve managed to get it as far as being recognised as a plugin that I can activate, and I’ve got an options page where I have a small form box where I can select my csv file.

    Only thing is when I press the “upload” button I get a white screen & it only uploads the first item on the csv.

    I’m guessing it’s just my poor php again, this is what I have at the form bit, I’m guessing its the 3 lines with the bold “echos” if anyone can help with this bit please – then I’ll be a really happy bunny ?? :

    function testcsv_plugin_page() {
    echo ‘<div class=”wrap”>’;
    echo ‘<h2>csvtest</h2>’;
    echo ‘<form enctype=”multipart/form-data” action=”” method=”POST”>’;
    echo ‘<input name=”uploaded” type=”file” class=”formbox1″ />’;
    echo ‘<input type=”submit” value=”Upload” class=”button” />’;
    echo ‘</form>’;
    echo ‘</div>’;
    }
    add_action( ‘admin_menu’, ‘testcsv_plugin_menu’ );
    ?>

    Thread Starter daveshu1

    (@daveshu1)

    PS – it works perfectly when csv is uploaded from the URL submission box, just not from within the admin panel.

    Also, the URL method has the php file stored in wp-admin, whilst the plugin attempt is in wp-content/plugins

    If any of that makes a difference?

    Hi this thread has been inactive for 2 months, but I’d like to add that I have just added a CSV feature to my plugin called Mass Page Maker.

    https://www.wesg.ca/2008/06/wordpress-plugin-mass-page-maker/

    With it, you can insert pages using a CSV and assign each individual post to which category you desire.

    dave did you ever get a working update of this script? i made the changes and it still doesnt work

    The easy way to accomplish this is to use the RSS import feature with your import file having the following for each post (item):

    <ITEM>
    <PubDate></PubDate>
    <Title></Title>
    <Description></Description>
    <Category></Category>
    </ITEM>

    The “category” entry needs to be spelled exactly as the existing category in WP.

    You don’t even have to include the standard feed file headers & footers.

    I recently imported a file with about 600 posts in about a minute.

    can’t get mass page maker to do posts. getting this error: Fatal error: Cannot use object of type WP_Error as array in /home/attorneysync/webapps/wp_cms_cacrimlawyer/wp-content/plugins/mass-page-maker/mass-page-maker.php on line 264

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘how to upload multiple posts & assign them to categories?’ is closed to new replies.