• Resolved mrrl

    (@mrrl)


    Hi,

    First off, great plug-in!

    I was wondering if it’s possible (when using [wpt_events]) to give the events of a specific category a class so they can get custom styling.

    For example I want all events from Category X to get a class="category_x" so they can get a custom coloured title or background colour.

    Basically class="wp_theatre_event category_x"

    • This topic was modified 6 years, 9 months ago by mrrl.
    • This topic was modified 6 years, 9 months ago by mrrl.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter mrrl

    (@mrrl)

    Got it working thanks to this old thread: https://wordpress.org/support/topic/add-a-custom-class-for-special-feature-eventsproductions/

    But it now only works on [wpt_events] (as initially requested) but I’d like it to work on [wpt_productions] listing as well.

    Not sure what to change to this code:

    function my_wpt_event_classes($classes,$event) {
      foreach($event->production->categories() as $categorie_id) {
        $cat = get_category( $categorie_id );
        $classes[] = $cat->slug;
      }
      return $classes;
    }
    add_filter('wpt_event_classes','my_wpt_event_classes', 10,2);
    Plugin Author Jeroen Schmit

    (@slimndap)

    This is the equivalent for [wpt_productions]:

    
    function add_category_class_to_production_html( $classes, $production ) {
    
      if ( ! empty( $production ) ) {
        $terms = wp_get_post_categories( $production->ID, array( 'fields' => 'slugs' ) );
        if ( ! empty( $terms ) ) {
          $classes[] = $terms[0];
        }
      }
    
      return $classes;
    }
    add_filter( 'wpt_production_classes', 'add_category_class_to_production_html', 10, 2 );
    
    Thread Starter mrrl

    (@mrrl)

    That’s it, thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Styling for categories in [wpt_events] list’ is closed to new replies.