Skip to content

Commit

Permalink
fix(homepage-posts): terms handling in category list (#1596)
Browse files Browse the repository at this point in the history
  • Loading branch information
DustyReagan authored Nov 16, 2023
1 parent a3a03df commit 55dbf42
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/blocks/homepage-articles/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -523,14 +523,16 @@ function newspack_blocks_format_categories( $post_id ) {
}
}

if ( ! is_a( $category, 'WP_Term' ) ) {
return '';
}

$category_link = get_category_link( $category->term_id );
$category_formatted = esc_html( $category->name );

if ( ! empty( $category_link ) ) {
$category_formatted = '<a href="' . esc_attr( $category_link ) . '">' . esc_html( $category->name ) . '</a>';
$category_formatted = '<a href="' . esc_url( $category_link ) . '">' . $category_formatted . '</a>';
}

if ( $category ) {
return apply_filters( 'newspack_blocks_categories', $category_formatted );
}
return apply_filters( 'newspack_blocks_categories', $category_formatted );
}

0 comments on commit 55dbf42

Please sign in to comment.