Viewing 3 replies - 1 through 3 (of 3 total)
  • Marcus Kober

    (@marcuskober)

    Hi there,

    could you please provide the code of the post type registration?

    Regards,
    Marcus

    Thread Starter facem Web

    (@shojikama)

    here for the post type

    function cptui_register_my_cpts_entreprises() {
    
    	/**
    	 * 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", "post-formats" ),
    		"taxonomies" => array( "caterogies_entreprises", "type_de_vente", "localisation", "immobilier_professionnel" ),
    	);
    
    	register_post_type( "entreprises", $args );
    }
    
    add_action( 'init', 'cptui_register_my_cpts_entreprises' );
    

    and here for the tax

    function cptui_register_my_taxes_caterogies_entreprises() {
    
    	/**
    	 * 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 );
    }
    
    add_action( 'init', 'cptui_register_my_taxes_caterogies_entreprises' );
    
    Marcus Kober

    (@marcuskober)

    Thank you.

    I expected the slug of the custom post type would say something like that:

    'rewrite' => array(
      'slug' => 'enterprises/%enterprise_cat%',
    ),

    Then there would have been a function that hooks into the filter ‘post_type_link’… But that’s not the case, isn’t it?

    Seeing the prefix ‘cptui_’, I assume you are using the Plugin Custom Post Type UI, don’t you?

    If that’s the case, try looking in the documentation of said plugin, because I don’t have used it by myself…

    Hope that helps.

    PLEASE NOTE: When changing slugs, please remember to flush the permalink cache, e.g. by visiting Settings -> Permalinks and hitting “Save changes”!

    Regards,
    Marcus

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘removing specific slug from url’ is closed to new replies.