Forum
Listing just the next event in every category
Hi,
I want to create a listing of events that only outputs the next event from each category (number of which will change over time). I can't define filter values for a date range in the future as the events are often infrequent and want the next event from each category to be listed. Is there a way I could just output the next event from each category in a date ascending list?
Have no code yet as I don't really know where to start :-(
Any help/guidance much appreciated.
I think you'd need to
Get the list of categories
Loop through the categories and get the next single event for each
Thanks, I'll give it a whirl and see how I get on.
Ok so far I've written this (through many trial and error syntax issues!) and this code actually renders the page which is progress. However still nothing outputs.
Any guidance gratefully received :)
Have you tried adding debug to the page so you can see what is going on?
https://solutions.grabaperch.com/development/how-do-i-debug-problems
I'm getting…
I don't know what any of this means, but it looks like it can't find the categories, or my code for the loop is wrong?
The first argument to
perch_events_category
needs to be the category slug.I think you probably want
perch_events_categories
instead.So I've changed it to ~~~perch_events_categories();~~~ so it now looks like this (i've echo'd $category to test the output of the variable:
This outputs:
I've have 3 categories and the loop happens 3 times which is correct and every date (four of them) is being listed which is also correct. I can't seem to get the categories to then loop through. It's outputting the $category as 'Array'. Not sure why
is outputting 'Array' as a string and not the category slugs? Do I need to add a filter to the first argument to get the category slug?
Can you change
to
What does it output then?
My suspicion is that this:
should be:
Outputs:
Ok, try: