Ordering blog_topics() by a custom order (not name or post count)
I have a blog listing template that lists "groups" of posts by blog topic. For example:
Topic 1
Post 1
Post 2
Topic 2
Post 3
Post 4
Topic 3
Post 5
Here's a link to a page using the actual template: https://www.neurotour.com/shows. Tours, Broadway, and Concerts are a few of the topics, and the "posters" listed under each of them are posts tagged with the topic.
Currently, I'm getting them by
set show_topics = blog_topics( 'shows', 100 )
However, it looks like you can only get blog_topics by name or post count. Does anyone know how to get the topics in a custom order?
The variable show_topics that you set returns a dictionery of values. Since this is a dict you can apply filters to it, allowing you to sort/order/filter/modify it however you like. The map, one of the most powerful filters, combined with any number of other will allow you to create anything you need.
Here we us the "~" to concatenate the values into the printable string you're looking for.
We use the "blog_recent_tag_post(…,250)" to get 250 of the most recent blogs with that tag as a dict and use the "count" (or length) filter to get the number of posts within that dict.
Let me know if this gets you going.
EDIT:
I'm not 100% if the "blog_recent_tag_post(……)" is case sensitive or not, but if it does cause issue you can use the "lower", "upper", "capitalize", or "title" filters to address the issue.
Note: Remember to use filters to pass modified values rather than modifing the original value.