From 77deddd2b85637f987140a1bd94defa1bf2929e9 Mon Sep 17 00:00:00 2001 From: Braad Date: Mon, 22 Jun 2015 13:14:21 -0700 Subject: [PATCH] Introduce trestle_post_classes to add custom classes to posts in certain situations --- includes/functions/theme-functions.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/includes/functions/theme-functions.php b/includes/functions/theme-functions.php index e5f8b21..79af02f 100755 --- a/includes/functions/theme-functions.php +++ b/includes/functions/theme-functions.php @@ -315,6 +315,26 @@ function trestle_custom_nav_extras( $nav_items, stdClass $menu_args ) { * Posts & Pages ===========================================*/ +add_filter( 'post_class', 'trestle_post_classes' ); +/** + * Add extra classes to posts in certain situations. + * + * @since 2.2.0 + * + * @param array $classes Post classes. + * @return array Updated post classes. + */ +function trestle_post_classes( $classes ) { + + // If post doesn't have a featured image. + if ( ! has_post_thumbnail() ) { + $classes[] = 'no-featured-image'; + } + + return $classes; + +} + add_filter( 'wp_revisions_to_keep', 'trestle_update_revisions_number', 10, 2 ); /** * Sets the number of post revisions.