think differentnew
asked 10 years ago

Hi Is there any option to hide a particular category which is showed in front end, I have a new category name called : computer. I would like to add an Rss feed for that particular category, But i don’t want to show that particular category in front end , Is there any way to make hide that particular category or tags do not make show in front-end , Thanks in advance.

2 Answers
DominicStaff
answered 10 years ago

Hi,
Please try the following code, you can add this code to the style.css file:

.dw_focus_widget_news_slider .carousel-entry .cat-links a {
  display: none;
}
.cat-links {
  color: #fff;
  text-indent: -9999px;
}
.cat-links a {
  text-indent: -9999px;
  position: absolute;
}

Hope this helps !

think differentnew
answered 10 years ago

Nope that does’t works , but i tried with this which is works perfect , Tried this with function.php

add_filter('get_the_terms', 'hide_categories_terms', 10, 3);

function hide_categories_terms($terms, $post_id, $taxonomy){

    // list of category slug to exclude, 
    $exclude = array('computer');

    if (!is_admin()) {
        foreach($terms as $key => $term){
            if($term->taxonomy == "category"){
                if(in_array($term->slug, $exclude)) unset($terms[$key]);
            }
        }
    }

    return $terms;
}
dominic Staff
replied 10 years ago

Awesome! I appreciate it.

Powered by DW Question & Answer Pro