Support » Plugin: Import any XML or CSV File to WordPress » Creating categories from titles or descriptions

  • Resolved blecha


    in my XML file there are products from different brands with titles such as:

    – Adidas Nemeziz 20.1 football boots
    – Nike Mercurial Superfly football boots
    – Puma King Pro football boots

    but in the XML file all the products are put in just one category “Football boots”

    I would like to create my own categories in woocommerce:

    – Adidas football boots
    – Nike football boots
    – Puma football boots

    and categorize products by titles (if title contains adidas > put into category adidas football boots).

    Is there any way how can do this? I suppose I will need to use category mapping tool (, but I do not know how. Should I use some PHP code?

    Thank you very much.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author WP All Import


    Hey @blecha,

    I’d suggest using a custom PHP function for this: Here’s an example function:

    For example, if the first word of the product title is always the brand, and you always want the category to be “Brand_name_here Football Boots”, you could use this:

    function my_pick_category( $title ) {
    	$title = explode( ' ', $title );
    	return reset( $title ) . ' Football Boots';

    Or, if you need to do a search for a word and then decide the category, something like this would work:

    function my_pick_category( $title ) {
    	$categories = array(
    		'Adidas' => 'Adidas Football Boots',
    		'Nike'   => 'Nike Football Boots',
    		'Puma'   => 'Puma Football Boots'
    	foreach ( $categories as $keyword => $category ) {
    		if ( stristr( $title, $keyword ) ) {
    			return $category;
    Thread Starter blecha


    Thank you very much.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.