08/18/2016 at 2:48 pm
#386979
Keymaster
@ Carolin
Yes, but not perfectly…
You can hook into the cn_entry_output_category_item filter and check for a “permitted” category ID and if one is not found return an empty string. Something like this:
add_filter( 'cn_entry_output_category_item', 'cn_remove_entry_output_category_item', 10, 6 );
function cn_remove_entry_output_category_item( $html, $category, $count, $i, $atts, $entry ) {
if ( in_array( $category->term_id, array( x, y ) ) ) {
return $html;
}
return '';
}
Change x and y in the code snippet to the two category ID/s that you want to be displayed. Al other will be tossed.
Now, I said this is not perfect… You’ll end up with “extra” commas where the categories should have been displayed — I think. If you do, the next update, I added extra logic, jujst now to make sure that will not happen.
Hope this helps!
