• Resolved Luca

    (@screenload)


    Is it possible by any means, to change the CSS on the page of PAST events only?

    My client wants the iCal and Google buttons hidden on past events ONLY!

    Scratching my head for hours… has anybody an idea?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hey there @screenload,

    Thanks for reaching out!

    We don’t really support customizations with our free support, but I’ll see if I can point you in the right direction.

    You can select td.tribe-events-past with CSS, you’ll likely need to target some other classes (best to use a tool like Chrome inspector or Firebug to find the classes you need. Our Themer’s Guide is a great resource for customizing The Events Calendar as well.

    Hope that helps!
    Ed ??

    Thread Starter Luca

    (@screenload)

    Hey Ed,

    thank you for your help. Could’t find td.tribe-events-past.
    So I did something rather complicated via PHP. It worked. Heres how I did it for everyone else:

    I added this code to the functions.php of my child theme:

    add_action( 'loop_start', 'tribe_events_insertion' ); // adds code inside the loop
    function tribe_events_insertion() {
    	if ( get_post_type( get_the_ID() ) == 'tribe_events' ) { // checking for the correct post type
    		
    		// checking start time of the current event
    		$thisID = get_the_ID();
    		$eventdate = get_post_meta( $thisID, $key = '_EventStartDate', true );
    		
    		// setting the timezone
    		date_default_timezone_set('Europe/Berlin');
    		$today = date("Y-m-d H:i:s");
    		if ($eventdate < $today) { // executing the code if event is in the past
    			echo "<style type=\"text/css\">.tribe-events-cal-links{display:none!important;}</style>"; // this css removes the buttons
    		}
    
    	}
    }

    Enjoy!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘CSS for past events ONLY’ is closed to new replies.