Hi, please go to file inc/templates/post-display-style-3.php
and replace following code
<div class="rpc-post-category">
<?php $categories = get_the_category();
$separator = ' , ';
$output = '';
if ( ! empty( $categories[0] ) ) {
$output .= '<a href="' . esc_url( get_category_link( $categories[0]->term_id ) ) . '">' . esc_html( $categories[0]->name ) . '</a>' . $separator;
echo trim( $output, $separator );
}
?>
</div>
with this one
<div class="rpc-post-category">
<?php $categories = get_the_category();
$separator = ' , ';
$output = '';
foreach ($categories as $cat) {
if ( ! empty( $cat ) ) {
$output .= '<a href="' . esc_url( get_category_link( $cat->term_id ) ) . '">' . esc_html( $cat->name ) . '</a>' . $separator;
echo trim( $output, $separator );
}
}
?>
</div>
Hi,
thanks a lot. but this displayed every category many times. I changed your code to this:
<div class="rpc-post-category">
<?php $categories = get_the_category();
$separator = ' , ';
$output = '';
foreach ($categories as $cat) {
if ( ! empty( $cat ) ) {
$output .= '<a href="' . esc_url( get_category_link( $cat->term_id ) ) . '">' . esc_html( $cat->name ) . '</a>' . $separator;
}
}
echo trim( $output, $separator );
?>
</div>
This means I put the “echo trim( $output, $separator );” after “foreach”. Now it works great!
Thank you for the quick answer!
-
This reply was modified 7 years, 2 months ago by
Svensson36.