This post will cover a complex WordPress query and nested loop to output custom posts organized by a custom taxonomy. Let’s run through the specifics of this particular example. In the example, we’ll be organizing posts for our “Movie” post type by the years they were created, which is a custom taxonomy called “movie years”.
1. Create a custom post type with a name of movie.
Before starting, I’ll be using the Genesis Framework so my code will be specific for Genesis. However, the loops and queries are universal and can be used in any WordPress theme. By the time we’re finished, the archive page will look something like this: