A default, or home state. This picks up the default posts, and it has a pagination parameter.

A collection state that gets a set of posts in a taxonomy term. The term is passed by slug, not ID. Note that the collection state and home states share the same component (and the same controller).

A single-post state. It passes year, month, and slug values in the URL.

The squash property in the params object. This means that if your parameter has the default value, in this case 1, it will not be shown in the URL. In practice, that if you are on page 1 of a collection, it won’t show pagination. Only subsequent pages have the ?page=2 string.

To make this work we need to have the year and month values correctly formatted in our data. I do this in the postsInCollection controller:

It requires the utility node-wpapi. This utility queries the wordpress database.

In the success handler, I filter each posts’ date object, to get simple strings for the year and the month, and add those data properties to the response.

After processing the data, I add it to the controller, and then apply it to the scope.

There are conditionals that format the node-wpapi query differently, depending on what parameters are passed in the state. This lets me get a list of tagged posts, or posts in a category, or just the default posts if no taxonomy slug is passed.

There are pagination functions that get a new set of posts without reloading the controller. That’s what notify: false does. Sweet!

Now in the template for collections, I can make links from the collection page to the single page this way:

And, also in your collection page, you can put in a older posts link this way. It calls the nextPage function that is defined in the collection controller. And the conditional means it won’t appear if there is no next page: