I have set up a custom post type and a custom taxonomy. Then I am displaying the list of taxonomies as a set of links so that if someone clicks on that link, it should bring up all the posts under that taxonomy. Currently this is not working. It keeps taking me to the 404 page with the 'This is somewhat embarrassing isn't it?' message.
Code is as follows:
FUNCTIONS.PHP
add_action( 'init', 'build_taxonomies', 0 );
function build_taxonomies() {
register_taxonomy( 'companies', 'companies', array( 'hierarchical' => true, 'label' => 'Company Categories', 'query_var' => true, 'rewrite' => true ) );
}
add_action('init', 'register_mypost_type');
function register_mypost_type() {
register_post_type('companies',array(
'labels' => array(
'name' => 'Companies',
'singular_name' => 'Company',
'add_new' => 'Add New Company',
'add_new_item' => 'Add New Company',
'edit_item' => 'Edit Company',
'new_item' => 'Add New Company',
'view_item' => 'View Company',
'search_items' => 'Search Companies',
'not_found' => 'No companies found',
'not_found_in_trash' => 'No companies found in trash'
),
'public' => true,
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt'),
'capability_type' => 'post',
'rewrite' => array('slug' => 'companies'),
'taxonomies' => array('category'),
'menu_position' => 7,
'has_archive' => true,
'hierarchical' => false
));
}
Then on another page called 'page-company.php' I use the following code to output the list of taxonomies as links:
<?php
$args = array( 'taxonomy' => 'companies' );
wp_list_categories( $args );
?>
When I hover over one of these links the URL is displayed as:
'http://localhost:81/?companies=graphic-design'
Graphic Design being one of the categories I have added to my custom taxonomy.
However clicking this link always takes me to the 404 page.
I have set up an archives page called archive-companies.php and I thought all of this would do the trick.
Any help that anyone can provide would be greatly appreciated.
Thanks in advance.