我有一个自定义的帖子类型,叫做cars。品牌有一个分类法。
我有一个模板的单车。php和我想添加一个链接到品牌页面(类别)。假设我在2013年帕萨特赛后的页面上。品牌为大众。我想展示大众品牌的永久魅力。
我的设置:功能。php
$labelsCars = array(
\'name\' => \'Cars\',
\'singular_name\' => \'Car\',
\'menu_name\' => \'Cars\',
\'add_new_item\' => \'Add New Car\',
\'edit_item\' => \'Edit Car\',
\'new_item\' => \'New Car\',
\'view_item\' => \'View Car\',
\'not_found\' => \'No Cars Found\'
);
$argsCars = array(
\'labels\' => $labelsCars,
\'public\' => true,
\'publicly_queryable\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'query_var\' => true,
\'rewrite\' => true,
\'capability_type\' => \'post\',
\'has_archive\' => true,
\'hierarchical\' => false,
\'menu_position\' => null,
\'supports\' => array(\'title\',\'editor\',\'page-attributes\',\'thumbnail\'),
\'exclude_from_search\' => true,
\'taxonomies\' => array(\'brands\')
);
register_post_type(\'cars\',$argsCars);
$labels = array(
\'name\' => \'Brands\',
\'singular_name\' => \'Brand\',
\'search_items\' => \'Search Brands\',
\'all_items\' => \'All Brands\',
\'edit_item\' => \'Edit Brand\',
\'update_item\' => \'Update Brand\',
\'add_new_item\' => \'Add New Brand\',
\'new_item_name\' => \'New Brand\',
\'menu_name\' => \'Brands\'
);
register_taxonomy(\'brands\',array(\'cars\'), array(
\'labels\' => $labels,
\'hierarchical\' => true,
\'show_ui\' => true,
\'query_var\' => true,
\'rewrite\' => array( \'slug\' => \'brands\' ),
\'show_in_nav_menus\' => true
));
单车。php
<?php get_header(); ?>
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<?php $content = get_the_excerpt(); ?>
<?php the_content() ?>
<?php echo \'<pre>\'.print_r(get_the_category($post->ID), 1).\'</pre>\'; ?>
<?php endwhile; // end of the loop. ?>
<?php get_footer(); ?>
这页是单人汽车。php显示一个空数组,而$post变量中填充了数据。
我一直在用谷歌搜索文档,当然也在这里,但我什么也没找到。。
我应该怎么做才能解决这个问题?