Support » Plugin: List Custom Taxonomy Widget » Order by recent usage?

  • I would like to order the list of tax terms by when they were last used in a post. Is there a way to “hack” that in, with a hook or something? (I know PHP and have a child theme, but I don’t have time right now to study your code.) Or would you consider a feature request to add it to the Order By choices?

    By the way, thanks for this nice little plugin that does exactly what it says it does. Kudos!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Nick Halsey

    (@celloexpressions)

    I would recommend creating your own solution (possibly based on this plugin’s code) to show recently-used terms. I’m not familiar with a core WordPress function that sorts terms by recently-used, but it seems like a good idea. You may want to suggest it on core trac.

    Thread Starter OsakaWebbie

    (@osakawebbie)

    Thanks. Are you saying that you would need something added to core in order to add that functionality to your plugin? If so, I don’t know what to ask for in core trac. The only core widget that lists taxonomies like yours, the Categories widget, doesn’t have any ordering options at all, so you’re probably not basing your widget on that.

    You suggested that I create my own solution (presumably you mean fork your plugin for my personal use). But my PHP background is in writing old-school raw code (including raw SQL queries) – adding a join/group-by/order-by would be simple if I had direct access to the SQL, but I have no idea how to do it through WordPress calls. If you, who are already familiar with WP development, are not just jumping in and doing it in your plugin, I assume it would be challenging or impossible for me to try.

    Thread Starter OsakaWebbie

    (@osakawebbie)

    I’ve dug into your plugin, and I think I see the issue. The orderby parameter of WP_Term_Query() would need an additional option called something like “recent_use” that would include MAX(wp_posts.post_date) in the query and then order by it. It no doubt already does a JOIN & GROUP BY with the wp_posts table in order to know the number of posts that use each term, so it shouldn’t be hard for the devs to add the max date. But I shudder to think how long it takes from when one lowly user suggests something until it appears in a new version of WP.

    For this particular site, I have a different idea of how to mitigate having a lot of terms that might not depend on changes to core. The terms fall into three broad types, so I could change the taxonomy to hierarchical and use a parent term to categorize them. Then I’d make three instances of your widget filtering by parent, and hopefully find a way to show only one at a time – I envision tabs or an accordion, although so far I haven’t found any tab or accordion widget that will accept another widget as its contents. If you know of anything in that vein, let me know.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Order by recent usage?’ is closed to new replies.