• Resolved c-systems

    (@coronasystems)


    Is there a way to change the background color of the tribe-events-single-events-title on the single event detail page based on the category selected for the event?

    I have a selection of categories and would like to have this element on the page color coded. I can use CSS but can’t see how to format it based on the category.

    Any help is appreciated.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi, coronasystems.

    Out of the box, The Events Calendar doesn’t have this capability, but you’re welcome to dive into customizing your install by checking out our Themer’s Guide:
    https://theeventscalendar.com/knowledgebase/themers-guide/

    You can pretty much customize any aspect of The Events Calendar this way.

    let me know if this helps.

    Mike

    Thread Starter c-systems

    (@coronasystems)

    Thanks for the reply. I have looked at the guide and while I was able to modify the colors on the single event page I am still unable to set a condition to allocate a color depending on the category.

    I would suggest creating a class based on the category slug. You can get an array o category slugs using this function:
    $slugs = tribe_get_event_cat_slugs($event_id);

    Then, loop through and add a class per slug (since there may be more than one) along with the .tribe-events-single class.

    Then you’ll be able to control all the elements within the template based on category, including the title.

    Does that help?

    Mike

    Thread Starter c-systems

    (@coronasystems)

    Once again thank you for your help.

    Would you be able to provide me with details on how to implement that solution, as it is beyond my current knowledge of wordpress.

    I assume it goes into functions.php but I don’t know how to write any additional code for the solution you provided.

    thanks

    Unfortunately, we’re limited to the amount of customization support we can provide here.

    Mike’s recommendation will require a bit more coding as he is providing you with a concept.

    Here’s an example of how to do this with a filter in your functions.php file, you’ll need to customize for your needs:

    add_filter('body_class','conf_class');
    function conf_class($classes) {
      if(in_the_loop()) { 
    	$post_id = get_the_ID(); 
      } else { 
    	$post_id = get_queried_object_id(); 
      }
    
    $terms = tribe_get_event_cat_slugs($event_id);
      foreach ($terms as $term) { 
        $eventCatSlug = $eventCatSlug . 'tribe_events-slug-' . $term;
      }
    
      $classes[] = $eventCatSlug;
      return $classes;
    } 

    Hope that helps!

    Hey there,

    Since this topic has been inactive for a while, I’m going to go ahead and mark as resolved. Don’t hesitate to reopen or create a new topic if you still need help! ??

    Take care,
    Ed ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Single Event Title color’ is closed to new replies.