WordPress.org

Forums

WordPress Importer
Fix for Duplicate Categories (3 posts)

  1. Jacob Schweitzer
    Member
    Posted 1 year ago #

    After finding out that it was the WordPress importer plugin causing imported custom posts to create multiple categories with a dash plus number on the end (Example: category, category-1, category-2) when they should be in the same category I figured out this fix for the problem. To be specific the problem was occurring with a custom post type which had a custom taxonomy associated with it ( Custom Post Type of Jobs, and a Custom Taxonomy of Job Categories).

    All of the changes are to the main plugin file, wordpress-importer.php .

    First I commented out line 645 so it should now look like this:

    //$term_id = is_array( $term_exists ) ? $term_exists['term_id'] : $term_exists;

    Immediately after this I added this code to replace it starting on line 646:

    if ( $term_exists !== 0 && $term_exists !== null ) {
         $term_id = $term_exists['term_id'];
    }
    else {
         unset($term_id);
    }

    Also, I commented out line 664 and changed the function from wp_set_post_terms to wp_set_object_terms:

    //$tt_ids = wp_set_post_terms( $post_id, $ids, $tax );
    $tt_ids = wp_set_object_terms( $post_id, $ids, $tax );

    I have changed wp_set_post_terms to wp_set_object_terms since the former just references the latter and in my case I was dealing with a custom post type / custom taxonomy, but this would still work properly without this last change.

    http://wordpress.org/plugins/wordpress-importer/

  2. trustdarkness
    Member
    Posted 7 months ago #

    I tried to adapt your fix to duplicate menus, but so far haven't had any luck.... any pointers?

  3. Jacob Schweitzer
    Member
    Posted 7 months ago #

    So it imports menus the same way ? menu-1, menu-2, etc.. when it was really the same menu?

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WordPress Importer
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic