我用分类法创建了一个自定义的帖子类型,当我转到分类法页面并查看其中一个分类法时,我会看到一个页面未找到错误,就像没有创建分类法一样。
有什么建议吗?
/*Products*/
$labels = array(
\'name\' => _x(\'Products\', \'post type general name\'),
\'singular_name\' => _x(\'Product\', \'post type singular name\'),
\'add_new\' => _x(\'Add New\', \'Product\'),
\'add_new_item\' => __("Add New Product"),
\'edit_item\' => __("Edit Product"),
\'new_item\' => __("New Product"),
\'view_item\' => __("View Product"),
\'search_items\' => __("Search Product"),
\'not_found\' => __(\'No products found\'),
\'not_found_in_trash\' => __(\'No products found in Trash\'),
\'parent_item_colon\' => \'\'
);
$args = array(
\'labels\' => $labels,
\'singular_label\' => __(\'Products\'),
\'public\' => true,
\'show_ui\' => true,
\'capability_type\' => \'post\',
\'hierarchical\' => false,
\'rewrite\' => true,
\'query_var\' => \'products\',
\'taxonomies\' => array(\'products-cat\'),
\'supports\' => array(\'title\', \'editor\', \'custom-fields\', \'thumbnail\', \'excerpt\'),
\'has_archive\' => true,
);
register_post_type( \'products\' , $args );
// Add to admin_init function
add_filter(\'manage_edit-products_columns\', \'add_new_products_columns\');
function add_new_products_columns($columns) {
$columns = array(
\'cb\' => \'<input type="checkbox" />\',
\'images\' => \'Images\',
\'title\' => \'Product Name\',
\'author\' => \'Author\',
\'product-categories\' => \'Categories\',
\'tags\' => \'Tags\',
\'date\' => \'Date\',
);
return $columns;
}
add_action(\'manage_products_posts_custom_column\', \'manage_products_columns\', 10, 2);
function manage_products_columns($column_name, $id) {
global $wpdb;
switch ($column_name) {
case \'images\':
//echo get_the_post_thumbnail( $page->ID, array(50,50) );
break;
case \'product-categories\':
echo get_the_term_list($post->ID, \'products-cat\', \'\', \', \',\'\');
break;
default:
break;
}
}
add_action( \'init\', \'products_create_taxonomies\', 0 );
function products_create_taxonomies()
{
// Photo Categories
register_taxonomy(\'products-cat\',array(\'products\'),array(
\'hierarchical\' => true,
\'label\' => \'Product Categories\',
\'singular_name\' => \'Products Category\',
\'show_ui\' => true,
\'query_var\' => true,
\'rewrite\' => array(\'slug\' => \'products\' )
));
}
/*End Products*/
我的档案页上有这个
归档产品。php
<?php get_header(); ?>
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post();?>
<?php the_title(); ?>
<?php endwhile; endif; ?>