if ( ! function_exists( 'themewich_create_taxonomies' ) ) :
function themewich_create_taxonomies() {
$labels = array(
'name' => _x( 'Filter', 'taxonomy general name', 'framework' ),
'singular_name' => _x( 'Filter', 'taxonomy singular name', 'framework' ),
'search_items' => __( 'Search Filters', 'framework' ),
'all_items' => __( 'All Filters', 'framework' ),
'parent_item' => __( 'Parent Filter', 'framework' ),
'parent_item_colon' => __( 'Parent Filter:', 'framework' ),
'edit_item' => __( 'Edit Filter', 'framework' ),
'update_item' => __( 'Update Filter', 'framework' ),
'add_new_item' => __( 'Add New Filter', 'framework' ),
'new_item_name' => __( 'New Filter Name', 'framework' ),
'menu_name' => __( 'Filters', 'framework' ),
);
register_taxonomy( 'filter',
array( 'portfolio', 'post' ),
array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'filter' ), // This is the url slug
)
);
}
使用以上代码新添了自定义文章类型
目录结构 URL 为
http://xxx.com/filter/aaa( http://xxx.com/filter/aaa(aaa 为自定义的目录别名)
文章结构 URL 为
http://xxx.com/portfolio/xxx
现在我想将目录结构的 url 更换为
http://xxx.com/aaa 也就是去除 filter
文章结构为
http://xxx.com/aaa/xxx
使用下面代码
if ( $post->post_type == 'portfolio' ){
return home_url( 'one/' . $post->ID .'.html' );
} else {
return $link;
}
文章结构变成了
http://xxx.com/one/xxx 而不是 aaa
求解 谢谢 不胜感激