Support

Home Forums Event Espresso Premium Multiple Categories on a Calendar

Multiple Categories on a Calendar

Posted: June 19, 2017 at 9:17 pm

Viewing 7 reply threads


wolfpack4417

June 19, 2017 at 9:17 pm

Hey I want to set up a calendar to show multiple categories. I tried setting up a parent category for all of the events called main-calendar and using this calendar code
[ESPRESSO_CALENDAR event_category_id=main-calendar]
I made each category have main-calendar as a parent but that’s still not working.


Josh

  • Support Staff

June 20, 2017 at 7:13 am

Hi Wolfpack,

Did you actually assign events to the main category? The calendar only shows events that are assigned to a category. It doesn’t show subcategories assigned to a parent category.


wolfpack4417

June 20, 2017 at 10:43 am

No they are assigned to the child categories. I want to keep the custom css (color and text color) of each category and show 4 categories on the same calendar. I figured that’s what the parent feature was for (what else would it be used for). How can I get 4 categories to show up on the same calendar?


Josh

  • Support Staff

June 20, 2017 at 10:57 am

The parent/child categories are more for things like URL structure, see also:
http://www.wpbeginner.com/beginners-guide/how-to-add-categories-and-subcategories-to-wordpress/

There really isn’t a way to specify 4 categories to show on one calendar. The calendar shortcodes are limited to either 1 category or all categories.


wolfpack4417

June 20, 2017 at 5:15 pm

I’m not that good with SQL queries, but couldn’t you find all events where category_id == <selected_id> or where parent_id == <selected_id> and push that functionality up really quick for me to use? I would do it myself but I don’t know wordpress that well. If you point me in the direction of that section of code though I might take a look and see if I can figure it out.


Josh

  • Support Staff

June 21, 2017 at 3:33 pm

So right now the event_category_id shortcode parameter will make the calendar get all events that belong to a category ID (not an array of category IDs though). The parent category ID idea will not work because as you mentioned, you’re not actually assigning events to the parent category.

There is a filter hook you can use to modify the calendar query, here’s an example that shows how to pass an array of category slugs:

https://gist.github.com/joshfeck/8f1e30feae874f9092d61b8ae3bf5f74

You can add the above to a functions plugin.

You’ll replace the array of category slugs on line 8 in the example with your array of category slugs.


wolfpack4417

June 28, 2017 at 11:29 pm

Hey I’ll take a look at the function plugin this week, but the parent category id would work I’m pretty sure, I just took a look in the db and there is a reference to the parent id. I could write a SQL query and give it to you if you want, you would just have to put it where it needs to go in the code.


Josh

  • Support Staff

June 30, 2017 at 11:28 am

Hi wolfpack4417,

Tony is actually working on something along these lines. He hasn’t published a branch yet, but if and when that happens the branch will be available here:

https://github.com/eventespresso/ee4-events-calendar/branches

Viewing 7 reply threads

The support post ‘Multiple Categories on a Calendar’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso