WordPress Importer
Fix for Duplicate Categories (3 posts)

  1. Jacob Schweitzer
    Posted 2 years 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 {

    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.


  2. trustdarkness
    Posted 1 year ago #

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

  3. Jacob Schweitzer
    Posted 1 year 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