WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

hi i'm using the Categories widget show hierarchy. I leave the space for title because I don't need to show any title. but it then displays on the website as "Categories". how can I remove that?

share|improve this question
up vote 1 down vote accepted

There is a filter you can use to do this. (Kruti has even found it, but instead of using it, he modified core files...)

$title = apply_filters('widget_title', empty( $instance['title'] ) ? __( 'Categories' ) : $instance['title'], $instance, $this->id_base);

So what you really need to do, is to add this to your functions.php:

function my_repair_categories_empty_title($title, $instance, $base) {
    if ( $base == 'categories' ) {
        if ( trim($instance['title']) == '' )
            return '';
    }
    return $title;
}
add_filter('widget_title', 'my_repair_categories_empty_title', 10, 3);
share|improve this answer
    
i added this code in functions.php and it works well. but i have a doubt.is this function affect any other widget's title in future??sorry if my doubt is unnecessary. – USER5615 Nov 26 '13 at 10:40
    
It will affect any categories widget. No other widgets should be affected. – Krzysiek Dróżdż Nov 26 '13 at 11:17

add_filter for widget_title does not allow more than one parameter when called so the above will throw PHP warnings.

This seems to work instead:

function my_repair_categories_empty_title() {
    if ( $base == 'categories' ) {
        if ( trim($instance['title']) == '' )
            return '';
    }
    return $title;
}
add_filter('widget_title', 'my_repair_categories_empty_title');

(tried to add this as a Comment to Krzysiek Dróżdż but don't have enough rep to do so)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.