1

I'm getting a 404 page when I visit my custom taxonomy page. Custom taxonomy is called 'manufacturer'. I also have a cpt called 'product'.

EDIT 1: It has something to do with the cpt rewrite. If I disable the rewrite, taxonomy works fine.

Few notes:

  • permalinks flush doesn't help
  • template taxonomy-manufacturer.php exists
  • WP version is 4.4.2
  • wp category has base 'kategorie'
  • post url is set to 'Post name'
  • cpt should have 'pretty url' (without any prefixes)

This is CPT 'product':

        function product_post_type() {

    $labels = array(
        'name'                  => _x( 'Products', 'Post Type General Name' ),
        'singular_name'         => _x( 'Product', 'Post Type Singular Name' ),
        'menu_name'             => __( 'Products' ),
        'name_admin_bar'        => __( 'Product' ),
        'archives'              => __( 'Products Archives' ),
        'parent_item_colon'     => __( 'Parent Product:' ),
        'all_items'             => __( 'All Products' ),
        'add_new_item'          => __( 'Add New Product' ),
        'add_new'               => __( 'Add New' ),
        'new_item'              => __( 'New Product' ),
        'edit_item'             => __( 'Edit Product' ),
        'update_item'           => __( 'Update Product' ),
        'view_item'             => __( 'View Product' ),
        'search_items'          => __( 'Search Product' ),
        'not_found'             => __( 'Product Not found' ),
        'not_found_in_trash'    => __( 'Product Not found in Trash' ),
        'featured_image'        => __( 'Featured Image' ),
        'set_featured_image'    => __( 'Set featured image' ),
        'remove_featured_image' => __( 'Remove featured image' ),
        'use_featured_image'    => __( 'Use as featured image' ),
        'insert_into_item'      => __( 'Insert into product' ),
        'uploaded_to_this_item' => __( 'Uploaded to this product' ),
        'items_list'            => __( 'Products list' ),
        'items_list_navigation' => __( 'Products list navigation' ),
        'filter_items_list'     => __( 'Filter products list' ),
    );
    $args = array(
        'label'                 => __( 'Products' ),
        'description'           => __( 'Product Description' ),
        'labels'                => $labels,
        'supports'              => array( 'title', 'editor', 'thumbnail' ),
        'taxonomies'            => array( 'category' ),
        'hierarchical'          => false,
        'public'                => true,
        'show_ui'               => true,
        'show_in_menu'          => true,
        'menu_position'         => 5,
        'show_in_admin_bar'     => true,
        'show_in_nav_menus'     => true,
        'can_export'            => true,
        'exclude_from_search'   => false,
        'publicly_queryable'    => true,
        'query_var' => true,
        'capability_type'       => 'post',
        'rewrite' => array('slug' => '/'),
        'has_archive' => true
    );
    register_post_type( 'product', $args );
}
add_action( 'init', 'product_post_type', 0 );

And this is custom taxonomy 'manufacturer':

    function manufacturer_taxonomy(){
    $labels = array(
        'name'              => _x( 'Herstellers', 'taxonomy general name' ),
        'singular_name'     => _x( 'Hersteller', 'taxonomy singular name' ),
        'search_items'      => __( 'Search Hersteller' ),
        'all_items'         => __( 'All Hersteller' ),
        'parent_item'       => __( 'Parent Hersteller' ),
        'parent_item_colon' => __( 'Parent Hersteller:' ),
        'edit_item'         => __( 'Edit Hersteller' ),
        'update_item'       => __( 'Update Hersteller' ),
        'add_new_item'      => __( 'Add New Hersteller' ),
        'new_item_name'     => __( 'New Hersteller Name' ),
        'menu_name'         => __( 'Hersteller' ),
    );

    register_taxonomy( 'manufacturer', 'product', array(
        'hierarchical'      => true,
        'labels'            => $labels,
        'show_ui'           => true,
        'show_admin_column' => true,
        'query_var'         => true,
        'rewrite' => array(
            'slug' => 'hersteller',
            'with_front' => false
        ),
    ));
}
add_action('init','manufacturer_taxonomy',0);

Any idea would be great.

0

You cannot have a rewrite slug of '/'. Note that using a slug of '', which you will find floating around, will not work for the latest WordPress versions either. If you want a url like http://domain.com/custom-post, there are no bullet-proof solutions, but the answer to this question will give you some leads: Remove slug from custom post type post URLs

  • I did another wp installation, and changed the wp default "posts" to "products" ( and other labels attached to "posts" ), set permalinks to /%postname%/, and everything works fine. Removed the old cpt "products" and that's it. I think this is maybe the cleanest solution tomy problem. Not perfect, since it's post type "post", but it works. – mihajlo Apr 16 '16 at 14:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.