php - Hide (not remove) category name globally on wordpress blog -
i'm trying hide specific category name (e.g. called "featured") on whole wordpress blog. please note not want exclude post belongs specific category, want prevent actual category name showing anywhre, should invisible.
i found code snippet put in functions.php, , want, it's hiding category names post meta section, doesn't have effect on third party plugins category name still showing. can please in order worked specific plugin?
code in function.php hiding category name:
function the_category_filter($thelist,$separator=' ') { if(!defined('wp_admin')) { $exclude = array('featured'); $cats = explode($separator,$thelist); $newlist = array(); foreach($cats $cat) { $catname = trim(strip_tags($cat)); if(!in_array($catname,$exclude)) $newlist[] = $cat; } return implode($separator,$newlist); } else return $thelist; } add_filter('the_category','the_category_filter',10,2);
plungin's function looks this:
private function generate_post_categories( $post ) { // setting category list string. $post_cat_string = ''; // setting category list. $post_cat_list = ''; // fetching post category prefix wpml support. $post_category_prefix = ($this->icl_t) ? icl_t('orp post category prefix', 'post-category-prefix–' . $this->widget_id, $this->widget_args['post_category_prefix'] ) : $this->widget_args['post_category_prefix']; // checking post category prefix. if ( !empty( $this->widget_args['post_category_prefix'] ) ) { // building post category prefix html. $post_cat_string .= esc_html( $post_category_prefix ); } // retrieving categories array. $orp_categories = get_the_category( $post->id ); // checking if "post category link" option on. if ( 'yes' == $this->widget_args['post_category_link'] ) { // looping through categories array. foreach( $orp_categories $orp_cat ) { // fetching current category link. $orp_category_link = get_category_link( $orp_cat->cat_id ); // building html link atts. $linkatts = array( 'href' => $orp_category_link, 'title' => $orp_cat->cat_name ); // building category link html. $post_cat_list .= $this->orp_create_tag( 'a', $orp_cat->cat_name, $linkatts ) . esc_html( $this->widget_args['post_category_separator'] ); } } else { // looping through categories array. foreach( $orp_categories $orp_cat ) { // filling categories list. $post_cat_list .= $orp_cat->cat_name . esc_html( $this->widget_args['post_category_separator'] ); } } // right trimming last category separator on category list. $post_cat_string .= rtrim( $post_cat_list, esc_html( $this->widget_args['post_category_separator'] ) ); // returning post category html. return $this->orp_create_tag( 'div', $post_cat_string, array( 'class' => 'orp-post-category' ) );
could try change part:
// looping through categories array. foreach( $orp_categories $orp_cat ) {
to :
// looping through categories array. foreach( $orp_categories $orp_cat ) { if($orp_cat->cat_name == 'featured') { continue; }
that should skip loop if category name equal "featured".
Comments
Post a Comment