How to get mixed list of subcategories and posts from specified category in alphabetical order?

I have category that looks like that:

category 1

  • subcategory 1
    • post 1-1
    • post 1-2
  • another subcategory 2
    • post 2-1
  • post 1
  • post 2
  • post 3

What I’m trying to achieve is list of posts and subcategories of category 1:

another subcategory 2
post 1
post 2
post 3
subcategory 1

ie in alphabetical order and without posts from subcategories.

I can get list of subcategories (using get_categories), I can get list of posts (using get_posts) but I’m not able to get both in one list that can be in A-Z order.

Thank you in advance for any hint that might help!


Source: wordpress

Leave a Reply