From 7748800a48f837112222b53cad7c762d883d3973 Mon Sep 17 00:00:00 2001 From: "David A. Kennedy" Date: Fri, 27 Jan 2017 22:08:37 +0000 Subject: [PATCH] Bundled Themes: Allow category display in post preview even when only one category The category is not shown in the preview. And because of how `themename_categorized_blog()` function in each theme returns false for 1 or fewer categories, and in this case it won't show the new category. The patch uses `is_preview()` to fix that in Twenty Fourteen, Fifteen and Seventeen. Props lancewillett. Fixes #39531. git-svn-id: https://develop.svn.wordpress.org/trunk@40023 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-content/themes/twentyfifteen/inc/template-tags.php | 2 +- src/wp-content/themes/twentyfourteen/inc/template-tags.php | 2 +- src/wp-content/themes/twentyseventeen/inc/template-tags.php | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/wp-content/themes/twentyfifteen/inc/template-tags.php b/src/wp-content/themes/twentyfifteen/inc/template-tags.php index fb6004ec38..f4de1d58bf 100644 --- a/src/wp-content/themes/twentyfifteen/inc/template-tags.php +++ b/src/wp-content/themes/twentyfifteen/inc/template-tags.php @@ -150,7 +150,7 @@ function twentyfifteen_categorized_blog() { set_transient( 'twentyfifteen_categories', $all_the_cool_cats ); } - if ( $all_the_cool_cats > 1 ) { + if ( $all_the_cool_cats > 1 || is_preview() ) { // This blog has more than 1 category so twentyfifteen_categorized_blog should return true. return true; } else { diff --git a/src/wp-content/themes/twentyfourteen/inc/template-tags.php b/src/wp-content/themes/twentyfourteen/inc/template-tags.php index f63ee8284b..1d35d0d5b9 100644 --- a/src/wp-content/themes/twentyfourteen/inc/template-tags.php +++ b/src/wp-content/themes/twentyfourteen/inc/template-tags.php @@ -140,7 +140,7 @@ function twentyfourteen_categorized_blog() { set_transient( 'twentyfourteen_category_count', $all_the_cool_cats ); } - if ( 1 !== (int) $all_the_cool_cats ) { + if ( $all_the_cool_cats > 1 || is_preview() ) { // This blog has more than 1 category so twentyfourteen_categorized_blog should return true return true; } else { diff --git a/src/wp-content/themes/twentyseventeen/inc/template-tags.php b/src/wp-content/themes/twentyseventeen/inc/template-tags.php index f94e3c9c87..782a81fe3b 100644 --- a/src/wp-content/themes/twentyseventeen/inc/template-tags.php +++ b/src/wp-content/themes/twentyseventeen/inc/template-tags.php @@ -177,6 +177,11 @@ function twentyseventeen_categorized_blog() { set_transient( 'twentyseventeen_categories', $category_count ); } + // Allow viewing case of 0 or 1 categories in post preview. + if ( is_preview() ) { + return true; + } + return $category_count > 1; }