I made a custom post type with taxonomies and when I go to the taxonomy page and view one of the taxonomies I get a page not found error like the taxonomy wasnt made.
Any suggestions?
/*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*/
I have this in my archives page
archive-products.php
<?php get_header(); ?>
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post();?>
<?php the_title(); ?>
<?php endwhile; endif; ?>