WordPress Permalink with custom post type and custom taxonomy

前端 未结 1 2040
礼貌的吻别
礼貌的吻别 2021-01-26 12:42

I have a custom post type called product and a custom taxonomy for products called product_types, which is hierarchical, so I have sub-categories in it.

I want the perm

相关标签:
1条回答
  • 2021-01-26 13:16

    firstly I would double check the function which is creating your custom post type, within that function there should be an element called: rewrite

    ie:

    register_post_type( 'products',
       'menu_position' => 25, // below pages
       'public' => true,
       'show_ui' => true,
       'rewrite' => array( 'slug' => 'product' ) <-- this is what you need!
    );
    

    also check the register_taxonomy function for the same!

    ie:

     register_taxonomy(
      'team',array('product_types'), 
        array(
        'public' => true,
        'show_ui' => true,
        'show_in_nav_menus' => true,
        'query_var' => true,
        'hierarchical' => true, <-- this is needed!
        'rewrite' => true <-- this is what you need!
      )); 
    

    the only thing left to check is:

    your permalink structure is set to /%postname%/ you may have to reset to default, save it, then re-set to /%postname%/ and save,

    hope that helps :)

    Marty

    0 讨论(0)
提交回复
热议问题