Skip to content

Commit 878cf4a

Browse files
Merge pull request #363 from zymeth25/hotfix-current-category
Fix current category for posts displayed in the loop.
2 parents 0d25707 + 84a20e3 commit 878cf4a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

include/lcp-category.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,13 @@ public function current_category($mode){
6565
$category = get_category( get_query_var( 'cat' ) );
6666
if( isset( $category->errors ) && $category->errors["invalid_term"][0] == __("Empty Term.") ){
6767
global $post;
68-
// Since WP 4.9 global $post is nullified in text widgets
69-
// when is_singular() is false.
70-
if (is_singular()) {
68+
/* Since WP 4.9 global $post is nullified in text widgets
69+
* when is_singular() is false.
70+
*
71+
* Added in_the_loop check to make the shortcode work
72+
* in posts listed in archives and home page (#358).
73+
*/
74+
if ( is_singular() || in_the_loop() ) {
7175
$categories = get_the_category($post->ID);
7276
}
7377
if ( !empty($categories) ){

0 commit comments

Comments
 (0)