admin管理员组文章数量:1122832
I've created a custom taxonomy for posts using
register_taxonomy(
'discipline',
array('post'), /* if you change the name of register_post_type( 'custom_type', then you have to change this */
array(
'hierarchical' => true, /* if this is true it acts like categories */
'labels' => array(
'name' => __( 'Disciplines' ), /* name of the custom taxonomy */
'singular_name' => __( 'Discipline' ), /* single taxonomy name */
'search_items' => __( 'Search Disciplines' ), /* search title for taxomony */
'all_items' => __( 'All Disciplines' ), /* all title for taxonomies */
'parent_item' => __( 'Parent Discipline' ), /* parent title for taxonomy */
'parent_item_colon' => __( 'Parent Discipline:' ), /* parent taxonomy title */
'edit_item' => __( 'Edit Discipline' ), /* edit custom taxonomy title */
'update_item' => __( 'Update Discipline' ), /* update title for taxonomy */
'add_new_item' => __( 'Add New Discipline' ), /* add new title for taxonomy */
'new_item_name' => __( 'New Discipline Name' ) /* name title for taxonomy */
),
'rewrite' => array(
'slug' => 'discipline',
'with_front' => false
),
'show_ui' => true,
'query_var' => true,
)
);
If I use just %postname% in the permalinks page, I get URLs like:
whatever/discipline/name-of-post
I want to get the URL to read
whatever/parent-term-name/name-of-post
I've removed the discipline part using the "Remove Taxonomy Base Slug" plugin but can't figure out how to get the term name included AND have permalinks to other parts of the site unaffected.
I've created a custom taxonomy for posts using
register_taxonomy(
'discipline',
array('post'), /* if you change the name of register_post_type( 'custom_type', then you have to change this */
array(
'hierarchical' => true, /* if this is true it acts like categories */
'labels' => array(
'name' => __( 'Disciplines' ), /* name of the custom taxonomy */
'singular_name' => __( 'Discipline' ), /* single taxonomy name */
'search_items' => __( 'Search Disciplines' ), /* search title for taxomony */
'all_items' => __( 'All Disciplines' ), /* all title for taxonomies */
'parent_item' => __( 'Parent Discipline' ), /* parent title for taxonomy */
'parent_item_colon' => __( 'Parent Discipline:' ), /* parent taxonomy title */
'edit_item' => __( 'Edit Discipline' ), /* edit custom taxonomy title */
'update_item' => __( 'Update Discipline' ), /* update title for taxonomy */
'add_new_item' => __( 'Add New Discipline' ), /* add new title for taxonomy */
'new_item_name' => __( 'New Discipline Name' ) /* name title for taxonomy */
),
'rewrite' => array(
'slug' => 'discipline',
'with_front' => false
),
'show_ui' => true,
'query_var' => true,
)
);
If I use just %postname% in the permalinks page, I get URLs like:
whatever.com/discipline/name-of-post
I want to get the URL to read
whatever.com/parent-term-name/name-of-post
I've removed the discipline part using the "Remove Taxonomy Base Slug" plugin but can't figure out how to get the term name included AND have permalinks to other parts of the site unaffected.
Share Improve this question edited Aug 14, 2014 at 22:53 Gabriel 2,24810 gold badges22 silver badges24 bronze badges asked Aug 14, 2014 at 19:21 user1729819user1729819 12 bronze badges1 Answer
Reset to default 0I think you need to include the discipline variable in the custom permalink structure
/%discipline%/%postname%
本文标签: Permalink Rewrite to include Custom Taxonomy Term
版权声明:本文标题:Permalink Rewrite to include Custom Taxonomy Term 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736297953a1930122.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论