• Resolved facem Web

    (@shojikama)


    Hi there,

    I have an issue with subcategories.
    When I create a cpt that have more that one level of category, it create a 404 error.

    The point is that instead of creating kind of : domain.fr/cat1/cat2/page url, it seemes to create both domain.fr/cat2/page and domain.fr/cat1/page.

    I can I enable the subcategories for cpt ?

    Thanks

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    If you’re registering this taxonomy using CPTUI, make sure that it’s set to be hierarchical, in case it’s not. That enables the parent/child relationship.

    Regarding the urls themselves, I believe that’s going to be a detail not directly handled by CPTUI. A lot of that is going to be the rewrite api/permalink setup. I’m not personally aware of out-of-box support to showing term archives with all of the terms in the url, but I’m willing to be wrong there. This would explain why the domain.fr/cat2/page and domain.fr/cat1/page version works.

    Thread Starter facem Web

    (@shojikama)

    cpt and custom tax are both on hierarchical true. For now, I have no clue about how have good urls for more than one categorie level.

    The CPT have /%custom_category%/%postname%/ permalink setup. But it doesn’t work like it should be. The singles have the same setup (/%category%/%postname%/) and have no issues.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    It’s all sounding like default behavior from what I can see.

    What permalinks are you using, including any special values there?
    What rewrite settings are you using for your post types and taxonomies created?

    Thread Starter facem Web

    (@shojikama)

    Here are the current settings for all cpt and ctax:

    function cptui_register_my_cpts() {
    
    	/**
    	 * Post Type: entreprises.
    	 */
    
    	$labels = array(
    		"name" => __( "entreprises", "" ),
    		"singular_name" => __( "entreprise", "" ),
    	);
    
    	$args = array(
    		"label" => __( "entreprises", "" ),
    		"labels" => $labels,
    		"description" => "",
    		"public" => true,
    		"publicly_queryable" => true,
    		"show_ui" => true,
    		"show_in_rest" => false,
    		"rest_base" => "",
    		"has_archive" => true,
    		"show_in_menu" => true,
    		"exclude_from_search" => false,
    		"capability_type" => "post",
    		"map_meta_cap" => true,
    		"hierarchical" => true,
    		"rewrite" => array( "slug" => "entreprises", "with_front" => true ),
    		"query_var" => true,
    		"menu_icon" => "dashicons-admin-home",
    		"supports" => array( "title", "editor", "thumbnail", "excerpt", "trackbacks", "custom-fields", "page-attributes" ),
    		"taxonomies" => array( "caterogies_entreprises", "type_de_vente", "localisation", "immobilier_professionnel" ),
    	);
    
    	register_post_type( "entreprises", $args );
    }
    
    add_action( 'init', 'cptui_register_my_cpts' );
    
    function cptui_register_my_taxes() {
    
    	/**
    	 * Taxonomy: Catégories entreprises.
    	 */
    
    	$labels = array(
    		"name" => __( "Catégories entreprises", "" ),
    		"singular_name" => __( "Catégorie entreprise", "" ),
    	);
    
    	$args = array(
    		"label" => __( "Catégories entreprises", "" ),
    		"labels" => $labels,
    		"public" => true,
    		"hierarchical" => true,
    		"label" => "Catégories entreprises",
    		"show_ui" => true,
    		"show_in_menu" => true,
    		"show_in_nav_menus" => true,
    		"query_var" => true,
    		"rewrite" => array( 'slug' => 'caterogies_entreprises', 'with_front' => true, ),
    		"show_admin_column" => false,
    		"show_in_rest" => false,
    		"rest_base" => "",
    		"show_in_quick_edit" => false,
    	);
    	register_taxonomy( "caterogies_entreprises", array( "entreprises" ), $args );
    
    	/**
    	 * Taxonomy: types de vente.
    	 */
    
    	$labels = array(
    		"name" => __( "types de vente", "" ),
    		"singular_name" => __( "type de vente", "" ),
    	);
    
    	$args = array(
    		"label" => __( "types de vente", "" ),
    		"labels" => $labels,
    		"public" => true,
    		"hierarchical" => false,
    		"label" => "types de vente",
    		"show_ui" => true,
    		"show_in_menu" => true,
    		"show_in_nav_menus" => true,
    		"query_var" => true,
    		"rewrite" => array( 'slug' => 'type_de_vente', 'with_front' => true, ),
    		"show_admin_column" => false,
    		"show_in_rest" => false,
    		"rest_base" => "",
    		"show_in_quick_edit" => false,
    	);
    	register_taxonomy( "type_de_vente", array( "entreprises" ), $args );
    
    	/**
    	 * Taxonomy: localisations.
    	 */
    
    	$labels = array(
    		"name" => __( "localisations", "" ),
    		"singular_name" => __( "localisation", "" ),
    	);
    
    	$args = array(
    		"label" => __( "localisations", "" ),
    		"labels" => $labels,
    		"public" => true,
    		"hierarchical" => false,
    		"label" => "localisations",
    		"show_ui" => true,
    		"show_in_menu" => true,
    		"show_in_nav_menus" => true,
    		"query_var" => true,
    		"rewrite" => array( 'slug' => 'localisation', 'with_front' => true, ),
    		"show_admin_column" => false,
    		"show_in_rest" => false,
    		"rest_base" => "",
    		"show_in_quick_edit" => false,
    	);
    	register_taxonomy( "localisation", array( "entreprises" ), $args );
    
    	/**
    	 * Taxonomy: immobilier professionnel.
    	 */
    
    	$labels = array(
    		"name" => __( "immobilier professionnel", "" ),
    		"singular_name" => __( "immobilier professionnel", "" ),
    	);
    
    	$args = array(
    		"label" => __( "immobilier professionnel", "" ),
    		"labels" => $labels,
    		"public" => true,
    		"hierarchical" => false,
    		"label" => "immobilier professionnel",
    		"show_ui" => true,
    		"show_in_menu" => true,
    		"show_in_nav_menus" => true,
    		"query_var" => true,
    		"rewrite" => array( 'slug' => 'immobilier_professionnel', 'with_front' => true, ),
    		"show_admin_column" => false,
    		"show_in_rest" => false,
    		"rest_base" => "",
    		"show_in_quick_edit" => false,
    	);
    	register_taxonomy( "immobilier_professionnel", array( "entreprises" ), $args );
    }
    
    add_action( 'init', 'cptui_register_my_taxes' );
    

    permalink are for cpt are domain/post_type/custom_tax/title

    • This reply was modified 7 years ago by facem Web.
    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Well, you’re not “stuffing” too much in the rewrites for what CPTUI is registering, which is good. What I mean by that is “something/something” as the rewrite slug. You’re sticking to just one part aka “something”.

    That said, I’m curious and wondering if your rewrite rules aren’t successfully parsing that permalink construct like needed. This, admittedly, falls outside the areas of what CPTUI handles and supports. CPTUI is doing it’s job of registering with all those settings, but further customization would be needed.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Any new developments here @shojikama ?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘subcategories 404’ is closed to new replies.