Comments obsidianwebsolutions started the conversationMarch 5, 2020 at 7:47amI have the calendar setting set to show events by their associated category color. When I have multiple categories assigned to one event, is there anyway to choose which color takes priority without manually entering the color code? 877Zhivko repliedMarch 5, 2020 at 7:57pmHi,No, currently the calendar picks the color from the first event category found.You can add custom hook that can prioritize the category color.Add following code in your theme function.php file: add_action('stec_after_html', function() { ?> <script type="text/javascript"> (function ($) { /** * SETUP * ENTER PRIORITY CATEGORIES IDS [HIGHEST -> LOWEST] */ var priorityCategories = [302, 312]; function getPriorityColor(categories) { var color = false; $.each(priorityCategories, function () { var pId = parseInt(this, 10); $.each(categories, function () { if (this.id === pId) { color = this.color; return false; // break; } }); if (color){ return false; // break; } }); return color; } $.stecExtend(function (m) { $.each(m.calData.eventsPool, function () { var color; if (this.category.length <= 0) { return true; // continue; } color = getPriorityColor(this.category); if (color) { this.color = color; } }); }, 'onAddToEventsPool'); })(window.jQuery); </script> <?php}); You will have to change the categories id for priorityCategories (Check the SETUP comment) Stachethemes Developerobsidianwebsolutions repliedMarch 6, 2020 at 1:31amThanks. That should work for now. Sign in to reply ...
I have the calendar setting set to show events by their associated category color. When I have multiple categories assigned to one event, is there anyway to choose which color takes priority without manually entering the color code?
Hi,
No, currently the calendar picks the color from the first event category found.
You can add custom hook that can prioritize the category color.
Add following code in your theme function.php file:
You will have to change the categories id for priorityCategories (Check the SETUP comment)
Stachethemes Developer
Thanks. That should work for now.