I have been trying to build a filter fuctionality for blog posts. I would want to filter by taxonomy terms and by the year the post was published. So basically in the content I want to list all blog posts – on sidebar I would have all used taxonomy terms listed and also a list of all years/months when post have been published.

Additionally I want the filter to be reflected by the URL structure:

  • For a URL like domain.com/blog/2014 all posts from 2014 would be listed.

  • For a URL like domain.com/blog/cars only posts tagged with 'car' would be listed.

Is there a module to do this – or should this be done with views? I have been trying to do this with views now but with not much luck. Especially with the url I don't understand how i can do that. Or if there is some tutorials on somewhere – that would help also.


You're on the right track. Views is good way to solve this with Contextual Filters. You need to create a page view with the path blog. That will create a page example.com/blog that shows all blog posts.

Adding a Content: Created year contextual filter will set up a filter rule so that example.com/blog/XXXX filter the view by posts created on year XXXX.

For your last need, tag filtering, you're going to need to add another page view since a page view can't do a mixed contextual filtering; views doesn't know how to treat XXXX in example.com/blog/XXXX as both a year or tag.

See this post on how to set up a filter Content: Has taxonomy term ID filter that will you create something like example.com/tags/YYYY where YYYY is the name of your tag.

  • 1
    Thanks! But does this mean that I would need to have to different blog listing pages? example.com/blog where the yearly archive is and then example.com/blog-2 where the tag filtering is? This doesn't sound nice. On Wordpress this wouldn't be a problem at all.
    – user995317
    Apr 16 '15 at 5:56
  • To the end user, the result would look the same if you set it up right. I'd argue that most users don't even bother looking at the URL bar unless they're having to manually go to another address.
    – Shawn Conn
    Apr 16 '15 at 6:12
  • Wordpress is blogging software right out the box. It's fantastic for that. Drupal is more of an abstract CMS application. The flexible/extendable of Drupal comes at the cost of simplicity. If you're looking for out-of-the-box blogging with Drupal, you should checkout Drupal distributions that might your needs.
    – Shawn Conn
    Apr 16 '15 at 6:26

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.