我看了几篇文章试图破解这个问题。我认为这对了解更多的人来说很简单。详细信息:
主题:基于Roots starter构建的自定义主题WP:3.8.1自定义帖子类型:pre\\u owned\\u cars
我的自定义帖子类型很好用——我已经习惯了这样做。然而,分类法把我绊倒了。我让它与我函数中的代码一起工作。php文件,但我不知道如何显示分类法。我创建了分类法。php和更新的permalinks。
这是我的功能。分类法的php代码-我试图将分类法命名为“type”:
// add tags to pages
add_action( \'init\', \'register_taxonomy_types\' );
function register_taxonomy_types() {
$labels = array(
\'name\' => _x( \'Types\', \'types\' ),
\'singular_name\' => _x( \'Type\', \'types\' ),
\'search_items\' => _x( \'Search Types\', \'types\' ),
\'popular_items\' => _x( \'Popular Types\', \'types\' ),
\'all_items\' => _x( \'All Types\', \'types\' ),
\'parent_item\' => _x( \'Parent Type\', \'types\' ),
\'parent_item_colon\' => _x( \'Parent Type:\', \'types\' ),
\'edit_item\' => _x( \'Edit Type\', \'types\' ),
\'update_item\' => _x( \'Update Type\', \'types\' ),
\'add_new_item\' => _x( \'Add New Type\', \'types\' ),
\'new_item_name\' => _x( \'New Type\', \'types\' ),
\'separate_items_with_commas\' => _x( \'Separate types with commas\', \'types\' ),
\'add_or_remove_items\' => _x( \'Add or remove Types\', \'types\' ),
\'choose_from_most_used\' => _x( \'Choose from most used Types\', \'types\' ),
\'menu_name\' => _x( \'Types\', \'types\' ),
);
$args = array(
\'labels\' => $labels,
\'public\' => true,
\'show_in_nav_menus\' => true,
\'show_ui\' => true,
\'show_tagcloud\' => true,
\'show_admin_column\' => false,
\'hierarchical\' => true,
\'rewrite\' => array(
\'slug\' => \'used-cars\',
\'with_front\' => true,
\'hierarchical\' => true
),
\'query_var\' => true
);
register_taxonomy( \'types\', array(\'pre-owned-cars\'), $args );
}
非常感谢您的帮助!