我的自定义分类法是链接到年度存档,而不是链接到它的帖子。
我创建了一个名为“year”的自定义分类法,其中包含int(即200820092010等)。使用以下代码注册了自定义分类法。
// Add new "Years" taxonomy to Posts
register_taxonomy(\'year\', \'post\', array(
// Hierarchical taxonomy (like categories)
\'hierarchical\' => true,
// This array of options controls the labels displayed in the WordPress Admin UI
\'labels\' => array(
\'name\' => _x( \'Year\', \'taxonomy general name\' ),
\'singular_name\' => _x( \'Year\', \'taxonomy singular name\' ),
\'search_items\' => __( \'Search Years\' ),
\'all_items\' => __( \'All Years\' ),
\'parent_item\' => __( \'Parent Year\' ),
\'parent_item_colon\' => __( \'Parent Year:\' ),
\'edit_item\' => __( \'Edit Year\' ),
\'update_item\' => __( \'Update Year\' ),
\'add_new_item\' => __( \'Add New Year\' ),
\'new_item_name\' => __( \'New Year Name\' ),
\'menu_name\' => __( \'Years\' ),
),
// Control the slugs used for this taxonomy
\'rewrite\' => array(
\'slug\' => \'Years\', // This controls the base slug that will display before each term
\'with_front\' => false, // Don\'t display the category base before "/Years/"
\'hierarchical\' => true // This will allow URL\'s like "/Years/boston/cambridge/"
),
));
并使用下面的行响应了post下的年份分类法。
<?php echo get_the_term_list( $post->ID, \'year\', \'<li>\', \'</li><li>\', \'</li>\' ); ?>
我以同样的方式注册了另外两个分类法“player”和“team”,它们工作得很好。
在此方面的任何帮助都将不胜感激。