Edit Flow

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.

[sourcecode language=”php”]
/**
* 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 );
[/sourcecode]

Exit mobile version