What is the best and shortest way in Wordpress to get_categories ordered by last posted article?
Means that categories with recent posts should appear first, is it available somehow?
What is the best and shortest way in Wordpress to get_categories ordered by last posted article?
Means that categories with recent posts should appear first, is it available somehow?
Try it:
Get categories order by (post ID | post date | post modified date). Without any loop and fast!
I think the easiest way would be to loop through all of your posts ordered by
post_date
and then save the categories to an array. You can then loop through the categories and display them. They will be in order.Something like this:
Of course, as mentioned in the comment above you could also do it the other way around and loop through the categories first then sort the array. Something like this could do: