Title: Map categories
Last modified: January 11, 2022

---

# Map categories

 *  Resolved [juriix](https://wordpress.org/support/users/juriix/)
 * (@juriix)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/map-categories/)
 * Hello,
    I’m trying to import Categories into an already created Category, but
   every time I start the import, new categories and subcategories are created.
 * I have in my XML a category path that looks like this:
    Kids > Shoes > Sport,
   Run Kids > T-shirt Kids > Glasses
 * Now I would like to have the structure like this (WP manual created Category)
   
   Kids & Baby
 * I need the Kids content (category) to appear only under the Kids & Baby category,
   no subcategories and no new categories.
 * Can you advise me what I am doing wrong or how to set up the Rubrics?
 * Thank you very much for your help
    -  This topic was modified 4 years, 4 months ago by [juriix](https://wordpress.org/support/users/juriix/).
    -  This topic was modified 4 years, 4 months ago by [juriix](https://wordpress.org/support/users/juriix/).

Viewing 9 replies - 1 through 9 (of 9 total)

 *  Plugin Author [WP All Import](https://wordpress.org/support/users/wpallimport/)
 * (@wpallimport)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/map-categories/#post-15246135)
 * Hi [@juriix](https://wordpress.org/support/users/juriix/),
 * I can see that we’ve already been working on this issue with you via our support
   system, so let’s continue the discussion there to avoid confusion.
 *  Thread Starter [juriix](https://wordpress.org/support/users/juriix/)
 * (@juriix)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/map-categories/#post-15246293)
 * Ok, thank you.
 *  [wbartl](https://wordpress.org/support/users/wbartl/)
 * (@wbartl)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/map-categories/#post-15256831)
 * Hi,
    I am interested in this Solution, too. regards Wolfgang
 *  Thread Starter [juriix](https://wordpress.org/support/users/juriix/)
 * (@juriix)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/map-categories/#post-15257072)
 * Hello,
 * add this in All Import -> Settings
 *     ```
       //Map categories
       function my_translate_category($category) {
           if($category === 'Kids > Shoes') {
               return 'Kids & Baby';
           } else {
               return 'Nezařazené';
           }
       }
       ```
   
 * But I don’t know how to import into subcategories that are already in the system.
 * Regards
    -  This reply was modified 4 years, 4 months ago by [juriix](https://wordpress.org/support/users/juriix/).
 *  [wbartl](https://wordpress.org/support/users/wbartl/)
 * (@wbartl)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/map-categories/#post-15257096)
 * Hi,
    thank you, I will try this… regards
 *  Thread Starter [juriix](https://wordpress.org/support/users/juriix/)
 * (@juriix)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/map-categories/#post-15286247)
 * Hello,
 * I don’t know why some content doesn’t want to import under mapped categories.
 * E.g. the product “Adidas L” should be imported into “kids-baby”, but imported
   into “Uncategorized”.
 * Path from feed – Kids > Shoes > Sport, Run
 *     ```
        } elseif($category === 'Kids') {
               return 'kids-baby';
       ```
   
 * Kids (main category) has subcategories Shoes > Sport, Run
 * Since I tested the feed I thought that if the Product has only the main category
   it will be imported OK, but if the product has subcategories the content will
   be imported into “uncategorized”. Could it be that the import is set as “Each
   Post has just one Rubric” (Each Příspěvek has just one Rubrika)? If so, how to
   set the import to import the content with Subcategories into the correct Rubrics(
   categories) as well?
 * Thank you.
 *  Plugin Author [WP All Import](https://wordpress.org/support/users/wpallimport/)
 * (@wpallimport)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/map-categories/#post-15306449)
 * Hi [@juriix](https://wordpress.org/support/users/juriix/),
 * That’s happening because “Kids > Shoes > Sport, Run” does not === “Kids”. You’d
   have to update your code to use [strpos()](https://www.php.net/manual/en/function.strpos.php)
   or something similar to see if “Kids” exists in the string, rather than looking
   for an exact match.
 *  Thread Starter [juriix](https://wordpress.org/support/users/juriix/)
 * (@juriix)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/map-categories/#post-15319637)
 * Hello,
 * I have created this for POST
 *     ```
       add_filter('wp_all_import_is_post_to_create', 'my_is_post_to_create', 10, 3);
   
       //Map categories
       function my_translate_category($category) {
           if(strpos($category, 'Shoes') !== false) {
               return 'kids-baby';
       ```
   
 * but for Woocommerce Products it doesn’t work, Can you help me?
 * Thank you
 *  Thread Starter [juriix](https://wordpress.org/support/users/juriix/)
 * (@juriix)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/map-categories/#post-15319910)
 * Solved
 * Thank you.

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Map categories’ is closed to new replies.

 * ![](https://ps.w.org/wp-all-import/assets/icon-256x256.png?rev=2570179)
 * [WP All Import – Drag & Drop Import for CSV, XML, Excel & Google Sheets](https://wordpress.org/plugins/wp-all-import/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-all-import/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-all-import/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-all-import/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-all-import/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-all-import/reviews/)

## Tags

 * [category](https://wordpress.org/support/topic-tag/category/)
 * [map](https://wordpress.org/support/topic-tag/map/)

 * 9 replies
 * 3 participants
 * Last reply from: [juriix](https://wordpress.org/support/users/juriix/)
 * Last activity: [4 years, 4 months ago](https://wordpress.org/support/topic/map-categories/#post-15319910)
 * Status: resolved