Last night Tucker Hottes, Den Temple and I held the first Homebrew Website Club at The Keys in Scranton, PA. I really appreciate that HWC will force me to set aside some time to work on my personal site since it is often neglected for more pressing projects.
During HWC I began trying to fix my crufty URLs for post format filtering on WordPress. Unless I’m missing something, it doesn’t appear that WordPress has “standard” post format filtering out of the box. It can filter by every other post format – statuses, audio, images – but doesn’t for standard posts. I’m almost sure I am missing something. If anyone knows how to do this more elegantly please let me me know. However, I’ve added this functionality myself months ago and now those URLs are cruft free. You can see them in my sidebar.
To do this isn’t trivial. Here are the steps you need to follow:
- Use the query_vars filter to add your own filter variable (I use type, see my code here)
- Use add_rewrite_rule for both the type filter and type filter based on pages (see my code here)
- Use get_query_var and query_posts on your post index to filter posts by the type provided (see my code here)
- Once you have this in place, be sure to reset Permalinks in your WordPress Admin
I’m glad HWC gave me the time to finally fix this as it had been bothering me for a few months. Looking forward to the next HWC where I’ll tackle a few more Indieweb things I’ve been meaning to bolt on.