WordPress.org

Support

Support » How-To and Troubleshooting » Category Descriptions Don’t Show Up

Category Descriptions Don’t Show Up

Viewing 1 replies (of 1 total)
  • Hi

    I just did some testing with the default theme to see where this message comes from. If your theme has a category.php file, it will be in there. If not it will come from archive.php.

    From the default theme:

    <?php if (have_posts()) : ?>
    ------------ stuff here ------------
         <?php while (have_posts()) : the_post(); ?>
             ============ stuff here ============
         <?php endwhile; ?>
                ============ stuff here ===========
    	<?php else :
       	   if ( is_category() ) { // If this is a category archive
    		printf("<h2 class='center'>Sorry, but there aren't any posts in the %s category yet.</h2>", single_cat_title('',false));
    		}
    		get_search_form();
    	endif;
    ?>

    Your theme will have something similar. The code that prints the “not found” is at the bottom of the WordPress loop, the last code I included. What you need to do is replace the error message you are getting with a printout of the category description and anything else you want displayed.

    This will display the name and descrip at top when no posts in cat

    <?php $cat_id = get_query_var('cat');
    $cat_info = get_category($cat_id); ?>
    <h2><?php echo $cat_info->name; ?> - <?php echo $cat_info->description; ?></h2>

Viewing 1 replies (of 1 total)
  • The topic ‘Category Descriptions Don’t Show Up’ is closed to new replies.
Skip to toolbar