I recreated the same setup as you but in my case, using the same code, my links are working fine.
Can you give more information about the placement of the code (is it in functions.php
) and the enabled plugins?
I suggest trying another slug to ensure that there is no conflict with any of the enabled plugins. For example, you can modify the slug from books
to custom_theme_books
or any other prefix of your preference.