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

The code below creates a plugin that appends the contents of $content to "the_content" on the hompage. It works fine when I set $content to a static value. However, I'm trying to set it to draw out the site's active categories as a list. However, nothing happens when I set $content to wp_list_categories()

Ultimately, I want to hack into the wp_list_categories function and display the thumbnail image that's been assigned to the category (still have to enable the code to do that as well).

This is the first evolution of the plugin and I'm just attempting to get it to list the categories and descriptions before I build in the thumbnail support.

Plugin Name: List Categories with Thumbnail Images

add_filter( 'the_content', 'cb_category_listing' );

function cb_category_listing( $content )
    if ( is_home() ) {
//      $content .= '<p>Hello World!</p>';
        $cat_args['title_li'] = '';
        $myContent = wp_list_categories(apply_filters('widget_categories_args', $cat_args)); 
        $content .= $myContent;
    return $content;

add_action( 'init','cb_category_listing');
share|improve this question
up vote 0 down vote accepted

Hi @Scott B:

Your example doesn't work for me when I use if (is_home()) but does when I use if (is_front_page()). Is there any chance that is the problem?

Other than that it seems to work fine on my WordPress v3.0.3 install. Do you have other plugins that might be disabling the output of wp_list_categories()?

P.S. I'm assuming you are using add_action( 'init','cb_category_listing'); just for debugging and not as part of your plugin?

share|improve this answer

You should add argument echo to get returned html string of wp_list_categories, instead of displaying it:

$cat_args['echo'] = 0;
share|improve this answer

Your Answer


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.