Support » Plugins » sort posts by subcategory?

  • New to WordPress and would very much appreciate a point in the right direction on this:

    Building custom blog to display albums released by year. Primary categories exist for each year (1955, 1956, etc.) Within each primary category (year) are subcategories representing each month of that year.

    Posts (album descriptions) are assigned to both a year (primary category) and a month (subcategory). User navigates by selecting year (in sidebar) and seeing all albums released in that year.

    Have been able to accomplish this customization EXCEPT that posts returned are NOT sorted by month. Example:

    This looks right until you see the last album posting, which is November, and should appear before the December entries. Current sort order seems to be by post entry.

    (Note: Subcategories (months) are actually labeled as (01) January, (02) February, etc. in order to facilitate sorting. The number prefix is masked in display.)

    I am using the Custom Query String plugin in order to return all posts for Archive display and sort by category. I assumed that this sort would take into consideration the existence of subcategories and consider them in the sort criteria, but it apparently does not.

    I looked at the data tables, and I see that the post_category field in wp_posts is 0 (zero) for all of these posts, and the relationship between posts and categories is only defined in the wp_post2cat table.

    I’m guessing the cleanest way to accomplish this would be to sort by category, but ONLY if the category_parent field is > 0 (meaning that category is a subcategory).

    I’ve spent a good number of hours searching through the WordPress php code looking for the right place to modify the relevant query, but I’m ready to give up and ask for help.

    This seems like a fairly straightforward requirement (sorting by subcategory), and surprised there isn’t more info on it. Any assistance would be GREATLY appreciated. Thank you.

  • The topic ‘sort posts by subcategory?’ is closed to new replies.