将类别添加到自定义帖子类型永久链接

时间:2012-10-13 03:02:47

标签: wordpress wordpress-theming

所以我正在使用自定义主题,并希望为我们的文章创建自定义网址结构。 基本上我现在所拥有的是 - > site.com/article/article-slug 我需要像这样的网站/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", 

    )
  ); 

1 个答案:

答案 0 :(得分:0)

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