0

There seem to be a lot of variations of this type of question, but I have not been able to find one that matches my specific situation or that is less than 4 years old. We have WordPress 4.1.1

  1. I have a page of Past Conferences.
  2. Each Past Conference has a year category value.
  3. The year categories are subcategories of the Past Conferences category.
  4. On the Past Conferences page, I need the title of each Past Conference.
  5. I need these conferences grouped by year with the year category name showing.

I have considered wp_list-categories() as it takes a lot of arguments, but this function writes the categories without stopping for the post titles. What I needed is:

[start loop through child categories of the category for that page] print subcategory name [start inside loop through posts in that child category] print post title [end inner loop] [end outer loop]

(I'd love to just write a simple SQL query and be done with it, but I'm trying to use the WordPress functions.)

0

This is not an optimal answer, but it works well enough for the client to have a page that does what they want. Since I cannot seem to find a function that will do the nested loops as described above, I used a series of query objects, one for each year the client would like to list.

'$PastConferences2015 = new WP_Query('category_name=2015'); 'while ( $PastConferences2015 -> have_posts() ) : $PastConferences2015->the_post();

This is not an efficient method, in my opinion, because the rest of the code that chooses the fields they want to show is repeated. (I am using the Types plugin to provide the fields they want for the conferences. That is not relative to the question, but it is relative to the efficiency of the solution because each field is called individually and exists in its own layer.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.