You have a few issues –
-
You’re setting
query_var
to'book'
in your custom taxonomy, which is clashing with the query var for your custom post type. change that totrue
and it will default to the name of the taxonomy,'rating'
. -
There is no
has_archive
argument forregister_taxonomy
, though this is probably not effecting anything. This makes sense if you think about it, since a taxonomy term is always a form of archive. -
The last issue you may encounter is one of precedence – if multiple rewrite rules apply to a given URL, the one with highest precedence will be chosen. If you register your post type first, then your taxonomy, using your example
http://localhost/wordpress/book/rating/nice
, WordPress will think you want to load an attachment namednice
belonging to a book namedrating
. If you register your taxonomy first, then register your post type, your taxonomy will take precedence in this case and everything should work as expected.