0

所以我正在使用自定义主题,并想为我们的文章创建一个自定义 url 结构。基本上我现在拥有的是 -> site.com/article/article-slug 我需要一个永久链接,比如这个site.com/category-slug/article/article-slug

我正在使用的代码是:

register_taxonomy( 'article', 'article_type', array(    
'labels' => array(
    'name' => 'Article Categories' ,
    'singular_name' => _x( 'Article Category', 'taxonomy singular name' ),
    'search_items' =>  __( 'Search Article Categorys' ),
    'popular_items' => __( 'Popular Article Categorys' ),
    'all_items' => __( 'All Article Categorys' ),
    'parent_item' => null,
    'parent_item_colon' => null,
    'edit_item' => __( 'Edit Article Category' ), 
    'update_item' => __( 'Update Article Category' ),
    'add_new_item' => __( 'Add Article Category' ),
    'new_item_name' => __( 'New Article Category Name' ),
    'separate_items_with_commas' => __( 'Separate Article Categorys with commas' ),
    'add_or_remove_items' => __( 'Add or remove Article Categorys' ),
    'choose_from_most_used' => __( 'Choose from the most used Article Categorys' )
    ) , 
'hierarchical' => true, 
'query_var' => true,
'show_ui' => true,
'rewrite' => array('slug' => 'article-category') ) );
register_post_type( 'article_type',
    array(
      'labels' => array('name' => 'Article Manager', 'singular_name' => 'Articles' ),
  'query_var' => true,
'show_ui' => true,
   'public' => true,
  'hierarchical' => true, 
  'rewrite' =>  array('slug' => 'article','with_front' => TRUE),            
  'supports' => array ( 'title', 'editor','author', 'custom-fields', 'revisions', 'post-formats', 'trackbacks', 'comments','excerpt' ),
      'menu_icon' => get_template_directory_uri()."/PPT/img/admin/article.png", 

    )
  ); 
4

1 回答 1

0

设置>永久链接和/%category%/%taxonomy%/postname%/

于 2012-11-19T06:09:02.420 回答