Support » How-To and Troubleshooting » bulk add categories

bulk add categories

  • Chris McCoy


    this works fine in 2.9, but not in 3.0 and 3.0.1

    when creating categories with children, it doesnt show up in the manage category section, but if you goto make a post it shows up fine, when you goto categories, you have to edit the parent, and click update, then they show up in the category list.

    here is a trac entry from months ago, see it wasnt resolved.


    the format is as follows

    Finance/Mutual Funds
    Finance/Personal Finance
    Finance/Real Estate

    here is the code

    add_action('admin_menu', 'bulk_cat_menu');
    function bulk_cat_menu() {
        add_management_page('Category Import', 'Category Import', 10, __FILE__, 'bulk_add_cat');
    function bulk_add_cat() {
        global $wpdb;
        $cats = $_POST['bulk_category_list'];
        $s = split("\n", $cats);
        foreach($s as $cat){
            $cat = trim(preg_replace("![\r\n]+!", '', $cat));
            $cats = split('\/', $cat);
            $last_id = 0;
            foreach($cats as $c2){
                $last_id = wp_create_category($c2, $last_id);
    <div class="wrap nosubsub">
        <div class="icon32" id="icon-edit"><br/></div>
        <h2>Bulk Category Import</h2>
        <form name="bulk_categories" action="<?php echo htmlspecialchars($_SERVER['REQUEST_URI']) ?>" method="post">
            <strong>Enter a list of category names, one per line:</strong>
            <textarea name="bulk_category_list" rows="20" style="width: 99%;"></textarea>
            <p class="submit"><input type="submit" name="submit" value="Add categories"/></p>
Viewing 10 replies - 1 through 10 (of 10 total)
  • I take reference from this code and make a plugin which is able to create categories with multiple children. It works well with 3.0.


    Hope this would help.

    Qeustion is Jamc does that plugin allow the children to show up straight away in categories management list?

    Easy CSV Importer mass creates categories also, with or without creating posts. Same issue, users often think that it is failing because they only see parents on the category page.

    Create a category, delete it, refresh. Fixed. I communicate this to my users now and it avoids a lot of refund requests that used to require me to explain all this. But it would be great to remove the warning about this from the plugin interface.


    didnt know you could do that with easy csv, will have to login and get the latest version.

    Yes sure, I don’t market that fact much. Latest improvement to categories was ability to use multiple columns to create category descriptions. This is an idea I will be expanding on more later.

    6.4.4 is coming very soon, that is the version you should get.

    i just sent you an email for some reason no download is available for my account, it was there before.

    Making a new download area, well it is a full customer service plugin. Sending ECI about 20 times per day by email right now.

    I kind of ask for it by releasing new versions most weeks so I shouldn’t complain huh!

    Chris make sure you get a copy of the new CSV importer next year. I’ll give it to you for nothing 😉

    I will be blogging its release on the Easy CSV Importer blog to get some attention so if your subscribed to the ECI RSS you’ll stay updated. It is a plugin worth getting.

    so wont be ready until 2012?

    must be adding a lot of stuff

    Well I have a year of feedback and requests from ECI users plus a list of about 200 of my own ideas. Takes a lot of time just to plan it all, so that this time it works for the basic users and is still worth of developers.

    To pack all that in I need a far better interface, that alone is taking a long time.

    I’ll be re-writing most of ECI functions so not just a case of copy paste.

    Will be worth the wait but ye 2012 is all I can say.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘bulk add categories’ is closed to new replies.
Skip to toolbar