我创建了我的自定义帖子类型(bizdirectory),创建了一个新帖子(测试业务)和一个新类别(业务目录)。但是如果我将业务目录类别(slug=Business)添加到我的主导航中,链接会显示,它会注册为该类别,但会显示“找不到”。
如果我在我的网站(使用首页上的搜索栏)上搜索测试业务,它会找到它-它显示的URL是-http://www.domain.com/dev/?bizdirectory=test-business - 我的函数代码。php如下:
// Load Custom Post Type
function add_bizdirectory() {
$labels = array(
\'name\' => __( \'Businesses\', \'text_domain\' ),
\'singular_name\' => __( \'Business\', \'text_domain\' ),
\'add_new\' => __( \'Add New Business\', \'${4:Name}\', \'text_domain\' ),
\'add_new_item\' => __( \'Add New Business\', \'text_domain}\' ),
\'edit_item\' => __( \'Edit Business\', \'text_domain\' ),
\'new_item\' => __( \'New Business\', \'text_domain\' ),
\'view_item\' => __( \'View Business\', \'text_domain\' ),
\'search_items\' => __( \'Search Businesses\', \'text_domain\' ),
\'not_found\' => __( \'No Businesses found\', \'text_domain\' ),
\'not_found_in_trash\' => __( \'No Businesses found in Trash\', \'text_domain\' ),
\'parent_item_colon\' => __( \'Parent Business:\', \'text_domain\' ),
\'menu_name\' => __( \'Business Directory\', \'text_domain\' ),
);
$args = array(
\'labels\' => $labels,
\'hierarchical\' => true,
\'description\' => \'description\',
\'taxonomies\' => array( \'category\' ),
\'public\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'menu_position\' => 5,
\'show_in_nav_menus\' => true,
\'publicly_queryable\' => true,
\'exclude_from_search\' => false,
\'has_archive\' => true,
\'query_var\' => true,
\'can_export\' => true,
\'rewrite\' => true,
\'capability_type\' => \'post\',
\'supports\' => array( \'title\', \'editor\', \'author\', \'thumbnail\', \'custom-fields\', \'revisions\', \'post-formats\' ),
);
register_post_type( \'bizdirectory\', $args );
}
add_action( \'init\', \'add_bizdirectory\' );
// End
我尝试了所有的重写规则选项,除了从wp\\U选项中手动删除重写规则的选项,它没有出现在wp\\U选项中。非常感谢您能给我的任何帮助或建议:)