相同层级子代的相同自定义分类插件

时间:2016-08-30 作者:serraosays

我有一个自定义分类法(版本),并希望在URL结构中反映的分类法中有一个年/月层次结构。

/editions/2016/december
/editions/2017/december
/editions/2018/december
WordPress似乎不允许我在管理端创建这个。这可能吗?

以下是我在functions.php:

/* Editions Function */
function aa_editions_tax() {
  register_taxonomy( \'editions\', \'page\', array(
    \'labels\' => array(
      \'add_new_item\' => \'Add New Edition\',
      \'all_items\' => \'All Editions\',
      \'edit_item\' => \'Edit Edition\',
      \'menu_name\' => \'Editions\',
      \'name\' => \'Editions\',
      \'new_item\' => \'New Edition\',
      \'not_found\' => \'No Editions Found\',
      \'not_found_in_trash\' => \'No Editions Found in Trash\',
      \'parent\' => \'Parent of Edition\',
      \'search_items\' => \'Search Editions\',
      \'singular_name\' => \'Edition\',
      \'view_item\' => \'View Edition\'
    ),
    \'hierarchical\' => true,
    \'public\' => true,
        \'rewrite\' => array(
            \'hierarchical\' => true
        ),
    \'query_var\' => true,
    \'show_ui\' => true
  ));
}
add_action( \'init\', \'aa_editions_tax\' );

1 个回复
SO网友:The J

EDIT

因为在分类法中只能有唯一的术语段塞,所以应该使用“混合分类术语”url设置。

您可以检查this, 或者这个solution 包括创建自己的add_rewrite_rules.