I have successfully created a custom taxonomy 'Authors' for quotations by adding the following code in my child theme's functions.php:
/** * Add custom taxonomies */
function add_custom_taxonomies() {
// Add new "Authors" taxonomy to Posts
register_taxonomy('author', 'post', array(
'hierarchical' => true,
'labels' => array( 'name' => _x( 'Authors', 'taxonomy general name' ),
'singular_name' => _x( 'author', 'taxonomy singular name' ),
'search_items' => __( 'Search Authors' ),
'all_items' => __( 'All Authors' ),
'parent_item' => __( 'Parent author' ),
'parent_item_colon' => __( 'Parent author:' ),
'edit_item' => __( 'Edit author' ),
'update_item' => __( 'Update author' ),
'add_new_item' => __( 'Add New author' ),
'new_item_name' => __( 'New author Name' ),
'menu_name' => __( 'Authors' ), ),
'rewrite' => array(
'slug' => 'authors',
'with_front' => false,
'hierarchical' => true
),
));
}
add_action( 'init', 'add_custom_taxonomies', 0 );
Then I have added an 'author' from my WP admin. Next I added a post with author 'Abdul Kalam', an eminent scientist from India. The post is clearly displaying the hyperlinked author name (added some code in parent theme's single.php).
Next I duplicated parent theme's archive.php to taxonomy-authors.php to list all the 'authors'. Also created another duplicate of archive.php to taxonomy-authors-abdul-kalam.php to show all posts that are tagged with author abdul kalam.
Problem is, I get a 404 error page whenever I browse to example.com/authors/ or to example.com/authors/abdul-kalam/. I have flushed permalinks some 10-15 times but no luck.
What am I doing wrong?
PS: I have tried other Taxonomy names such as Personalities which doesn't work either! While 'author' may already exist and may not work, 'authors' should work.
author
is already a WordPress query var, you probably shouldn't use that name for your taxonomy, or at least set a different query var in your taxonomy registration..