I’d like get_the_category_list
to only display one or two categories instead of all the categories associated with the post. Haven’t been able to find any results.
<?php echo get_the_category_list(); ?>
Any help would be appreciated
I’d like get_the_category_list
to only display one or two categories instead of all the categories associated with the post. Haven’t been able to find any results.
<?php echo get_the_category_list(); ?>
Any help would be appreciated
$categories = get_the_category();
if ( ! empty( $categories ) ) {
echo '<a href="' . esc_url( get_category_link( $categories[0]->term_id ) ) . '">' . esc_html( $categories[0]->name ) . '</a>';
}