我非常需要你们的帮助。我正在尝试通过以下方式注册自定义帖子类型和分类:
add_action( \'init\', \'product_catalog\' );
add_action( \'init\', \'product_type\', 0 );
function product_catalog() {
$labels = array(
\'name\' => _x( \'Catalog\', \'post type general name\' ),
\'menu_name\' => \'Catalog\'
);
$args = array(
\'labels\' => $labels,
\'description\' => \'Catalog\',
\'public\' => true,
\'publicly_queryable\' => true,
\'show_ui\' => true,
\'query_var\' => true,
\'capability_type\' => \'post\',
\'hierarchical\' => false,
\'menu_position\' => 5,
\'supports\' => array( \'title\', \'editor\', \'thumbnail\', \'excerpt\', \'comments\' ),
\'has_archive\' => true,
"rewrite" => array(
\'with_front\' => false,
\'slug\' => \'catalog\'
)
);
register_post_type( \'product_catalog\', $args );
}
//taxonomy that wont work with first parent, all childs work just fine.
function product_type(){
register_taxonomy("product_type", array("product_catalog"), array(
"hierarchical" => true,
"label" => "Types",
"singular_label" => "Type",
"show_ui" => true,
\'show_admin_column\' => true,
\'query_var\' => true,
"rewrite" => array(
\'slug\' => \'type\',
\'with_front\' => false,
"hierarchical" => true
)
));
}
它似乎显示在面板中,我可以在类型下添加层次分类法,但如果我尝试转到url,则会出现问题,如:
sitename.com/type/parent 它总是返回404 not found。同时,我可以访问childs of TYPE,它加载得很好,如:
sitename.com/type/parent/child如果我更改\'slug\' => \'type\' 其他类似于:\'types\' 然后它就100%起作用了。
我不明白,为什么会发生这种事,它是为什么保留的吗?
我会感谢你的帮助。
非常感谢。