From dc4f5d8b53b8105190cf7892b7902a74fa45d60c Mon Sep 17 00:00:00 2001 From: Laurel Fulford Date: Tue, 11 Feb 2020 11:28:17 -0800 Subject: [PATCH] Feat: Add classes for the category and tags to the primary section, so the header can be styled. --- newspack-theme/inc/template-functions.php | 14 ++++++++++++++ newspack-theme/single-feature.php | 2 +- newspack-theme/single-wide.php | 2 +- newspack-theme/single.php | 2 +- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/newspack-theme/inc/template-functions.php b/newspack-theme/inc/template-functions.php index b84337659..dc96a77b6 100755 --- a/newspack-theme/inc/template-functions.php +++ b/newspack-theme/inc/template-functions.php @@ -166,6 +166,20 @@ function newspack_post_classes( $classes, $class, $post_id ) { } add_filter( 'post_class', 'newspack_post_classes', 10, 3 ); +/** + * Gets the category and tag classes from the post. + */ +function newspack_get_category_tag_classes( $post_id ) { + $post_classes = get_post_class( '', $post_id ); + $cat_tag_classes = array(); + foreach ( $post_classes as $post_class ) { + if ( 0 === strpos( $post_class, 'category-' ) || 0 === strpos( $post_class, 'tag-' ) ) { + $cat_tag_classes[] = $post_class; + } + } + return implode( ' ', $cat_tag_classes ); +} + /** * Add a pingback url auto-discovery header for single posts, pages, or attachments. */ diff --git a/newspack-theme/single-feature.php b/newspack-theme/single-feature.php index 5b7f94a6b..f1bb80468 100644 --- a/newspack-theme/single-feature.php +++ b/newspack-theme/single-feature.php @@ -13,7 +13,7 @@ get_header(); ?> -
+
-
+
-
+