I have a CPT called books and a custom taxonomy called genre and need to show in a page all books of a specific term and a specific year.

For that, I created taxonomy-genre.php file and created a get_posts query which work fine when the Permalink are disabled. The URL is:


Now I'm trying to create a rewrite rule:

add_action( 'init', function(){

But the website return not found.

  • 1
    WHY???? get_posts – Pieter Goosen Oct 14 '15 at 17:53
  • @PieterGoosen to grab all posts from a specific gender and specific year – marcelo2605 Oct 14 '15 at 17:54
  • pre_get_posts and the default main query loop is the correct way. Will also eliminate pagination issues, is faster and way better for performance – Pieter Goosen Oct 14 '15 at 17:56
  • @PieterGoosen OK I will try. But I can't see how this can solve my rewrite_rule issue. – marcelo2605 Oct 14 '15 at 17:57
  • 1
    ([a-z]) only matches one letter, change it to ([a-z]+). – Milo Oct 14 '15 at 18:37

Your Answer

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

Browse other questions tagged or ask your own question.