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.

  • It is impossible to read your code, everything is in one very lllloooonnnngggg line. Please clean up your code so we can actually read it – Pieter Goosen Mar 6 '16 at 3:27
  • @PieterGoosen After posting the question, I went to sleep since I am supposed to take a brief nap! :-) Woke up to the tring notifying me about the suggested edit by BillK and your downvote ;-) Your request is 1000% valid one and hope the code is visible now. Thanks! – Ramnath Mar 6 '16 at 7:09
  • 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.. – Milo Mar 6 '16 at 7:34
  • Right. That might be an issue. But all I need is upgrade/migrate the current multisite and keep the Permalink unchanged for SEO. /authors is already running in my current WP setup. – Ramnath Mar 6 '16 at 7:58
  • The current issue is not for multisite BTW. – Ramnath Mar 6 '16 at 8:20

The problem is this:

register_taxonomy('author', 'post', array( //tax args here... ));

The first argument, which is taxonomy name, you've set to author. WordPress uses that value as the taxonomy query var if a value isn't explicitly declared. When this taxonomy is queried, author is used to pass the requested term slug to the query.

The problem with that is that WordPress already uses author to query for users via their ID. Visiting those term pages results in WordPress trying to query for posts where user ID is 0, which will always be a 404 (any non-numeric string is interpreted as invalid and becomes integer 0).

Either change the name to something else:

register_taxonomy('something_unique', 'post', array( //tax args here... ));

Or, explicitly set query_var to something other than author.

register_taxonomy('author', 'post', array(
    'query_var' => 'something_unique',
    // the rest of your tax args...
| improve this answer | |
  • Gimme sometime to try this out and get back to you! – Ramnath Mar 6 '16 at 16:31
  • No success. What I really need is, /quotes/this-is-a-quote.html + /quotes/authors/some-author/ + /quotes/startup-quotes/ What are the other possible solutions to implement this? Pls suggest. – Ramnath Mar 6 '16 at 22:58
  • Why are you asking for something different if it's not what you actually need? Edit your question and add details, and show exactly what you've tried in a form that someone can test. – Milo Mar 6 '16 at 23:07
  • Yes my question differs. That is the present structure of my 'quotes' multi site where 'authors' is the tag base, and categories like 'Startup quotes' are simple categories. The current urls has got thousands of fb shares, good rankings. I am migrating to a new conventional wp setup (not a multi site). Question is will it be at all feasible to duplicate the multi site setup in a single wp installation ? (The scope of question changes to some extent) Or should I post a fresh question not limited to custom taxonomy archive? Apologies for the confusion. – Ramnath Mar 6 '16 at 23:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.