我似乎在使用与register_taxonomy _category和_tag相同的“弹子”出版物时遇到了问题。似乎只有最后一次调用register_taxonomy('publications_tag',才能使用这种弹格。与前面的调用一样,register_taxonomy('publications_category',呈现一个404。
我如何才能对类别和标记使用相同的段塞,然后我假设它将使用我的分类法-{post_..php模板?
//自定义邮政类型:
register_post_type( 'publications', $args );
$args = array(
'label' => __( 'Publication', 'text_domain' ),
'description' => __( 'Publications', 'text_domain' ),
'labels' => $labels,
'supports' => array(
'title',
'editor',
'thumbnail',
'excerpt',
'revisions',
'author',
'post-formats',
//'comments',
'page-attributes'
),
'taxonomies' => array(
'publications_category',
'publications_tag'
),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 20,
'menu_icon' => 'dashicons-align-left',
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
'has_archive' => 'publications',
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'post',
'show_in_rest' => true,
'rewrite' => array(
// 'slug' => 'publications',
'with_front' => false
),
);//类别:
register_taxonomy('publications_category', 'publications', array (
'labels' => array (
//
),
'hierarchical' => true,
'show_ui' => true,
'show_tagcloud' => true,
'rewrite' => array(
'slug' => 'publications',
'with_front' => false ),
'public' => true
)
);//标签:
register_taxonomy('publications_tag','publications', array(
'labels' => array (
//
),
'hierarchical' => false,
'rewrite' => array(
'slug' => 'publications',
'with_front' => false ),
)
);发布于 2018-08-10 10:45:44
因此,我为重写段塞添加了/标记或/类别,而不是添加publications或publications/%publications_tag%。我最初认为这两种分类法类型都可以存在于父post类型中,wordpress可以解决其余的问题。
标签:'rewrite' => array( 'slug' => 'publication/tag', 'with_front' => false ),
类似于:domain.test/publications/tag/example-tag/和use是axonomy-publications_tag.php文件。
类别:'rewrite' => array( 'slug' => 'publication/category', 'with_front' => false ),看起来像:domain.test/publications/category/example-category/和use的axonomy-publications_category.php文件。
https://wordpress.stackexchange.com/questions/310994
复制相似问题