Modify CSS classes applied to posts on the calendar

There are a few CSS classes wrapped around each post on the calendar by default. Customizing these further is just a matter of modifying the classes with the ef_calendar_table_td_li_classes filter.

If you haven’t already, please read the introduction to extending Edit Flow. Once you’ve done so, you can modify the example below to your needs. This particular example will add the post categories as additional CSS selectors.

/**
 * Modify CSS classes applied to posts on the calendar
 *
 * @see http://editflow.org/extend/modify-css-classes-applied-to-posts-on-the-calendar/
 *
 * @param array $post_classes Existing post classes
 * @param string $week_single_date The date this post appears on
 * @param int $post_id Unique identifier for the post we're modifying
 * @return array $post_classes Post classes after we've made any requisite modifications
 */
function efx_modify_calendar_post_css_classes( $post_classes, $week_single_date, $post_id ) {

	$categories = wp_get_post_categories( $post_id, array( 'fields' => 'slugs' ) );
	foreach( (array)$categories as $category ) {
		$post_classes[] = 'category-' . $category;
	}
	return $post_classes;
}
add_filter( 'ef_calendar_table_td_li_classes', 'efx_modify_calendar_post_css_classes', 10, 3 );

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: