show only active category in each faq post

This commit is contained in:
jorge 2023-02-22 23:27:02 +01:00
parent 9d6b78cbb4
commit cb916bc37e
2 changed files with 25 additions and 2 deletions

View File

@ -90,3 +90,25 @@ if ( ! function_exists( 'ofisuport_display_faqs_labels' ) ) :
<?php
}
endif; //end ofisuport_display_faqs_labels
/**
* Displays categories for each FAQ
*/
if ( ! function_exists( 'ofisuport_display_each_faq_categories' ) ) :
function ofisuport_display_each_faq_categories() {
$categories = get_the_category();
if ( ! empty( $categories ) ) {
echo ' <nav id="tipus-faqs" class="ofisuport-faqs-types">';
echo ' <ul class="ofisuport-label">';
foreach ( $categories as $category ) {
if ( ! ($category->cat_ID == '1') ) { //cat_ID '1' is defined as default FAQ
echo '<li class="cat-item"><a href="' . esc_url( get_category_link( $category->term_id ) ) . '">' . esc_html( $category->name ) . '</a></li>';
}
}
echo ' </ul>';
echo ' </nav>';
}
}
endif; //end ofisuport_display_each_faq_categories

View File

@ -19,7 +19,8 @@
?>
<div class="entry-meta">
<?php
ofisuport_display_faqs_labels();
ofisuport_display_each_faq_categories();
//ofisuport_display_faqs_labels();
//ofisuport_posted_on();
//ofisuport_posted_by();
?>