1

Kind a new to wordpress. Trying to add two new taxonomis to woocommerce:

  • product_color
  • product_category

The taxonomies are added and I see them under products categories, I even can add them to products.

The problem is when I try to enter the archive page.

In the product_category taxonomy every thing works fine, I enter the next uri product_category/asos/ and it works.

The problem happens when I try to enter the product_color archive page in the next uri product_color/red/ and I get 404 page

This is the code I placed in functions.php file.

/**
         * Create custom taxonomy for products
         * product_company
         */    
        function product_company() {
            $labels = array(

                'name'              => _x( 'manufacturer', 'manufacturer' ),
                'singular_name'     => _x( 'manufacturer', 'manufacturer'),
                'search_items'      => __( 'find a new manufacturer' ),
                'all_items'         => __( 'All manufacturers' ),
                'parent_item'       => __( 'category parent' ),
                'parent_item_colon' => __( 'category parent:' ),
                'edit_item'         => __( 'Edit manufacturer' ), 
                'update_item'       => __( 'Edit manufacturer' ),
                'add_new_item'      => __( 'Add a new manufacturer' ),
                'new_item_name'     => __( 'new manufacturer' ),
                'menu_name'         => __( 'יmanufacturers' ),

            );
        
        $args = array(
            'labels' => $labels,
            'hierarchical' => true,
            'query_var' => true,
            'rewrite' => true,
            'show_admin_column' => true,
            'public' => true,
            'show_ui'=> true,
            'show_admin_column '=> true,


        );
        
        register_taxonomy( 'product_category', 'product', $args );
                
    }
    add_action( 'init', 'product_company', 0 );


/**
         * Create custom taxonomy for products
         * product_color
         */    

    function product_color() {
            $labels = array(

                'name'              => _x( 'color', 'color' ),
                'singular_name'     => _x( 'color', 'color' ),
                'search_items'      => __( 'find by color' ),
                'all_items'         => __( 'all colors' ),
                'parent_item'       => __( 'category parent' ),
                'parent_item_colon' => __( 'category parent:' ),
                'edit_item'         => __( 'edit color' ), 
                'update_item'       => __( 'update color' ),
                'add_new_item'      => __( 'add color new' ),
                'new_item_name'     => __( 'new color' ),
                'menu_name'         => __( 'colors' ),

            );
        
        $args = array(
            'labels' => $labels,
            'hierarchical' => false,
            'query_var' => true,
            'rewrite' => true,
            'show_admin_column' => true,
            'public' => true,
            'show_ui'=> true,
            'show_admin_column '=> true,


        );
        
        register_taxonomy( 'product_color', 'product', $args );
                
    }
    add_action( 'init', 'product_color', 0 );
1
  • that looks good, so far. have you saved your permalink settings? usually when creating new post types or custom rewrite rules, you need to flush your rewrite rules. and that is done by going to settings > permalinks and simply save that page again. (this could also be done via php, but since you dont want/need to do that too often, that is the simplest way to do so..)
    – honk31
    Dec 16, 2020 at 12:34

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.