Category Descriptions Don't Show Up (2 posts)

  1. luckycharmz337
    Posted 5 years ago #

    I am working on a new project at http://www.arizonamansions.org/ and I am trying to get the category descriptions to work. For example, I created a page at http://www.arizonamansions.org/category/7277-scottsdale-residences/ and I have a description listed in the admin side.

    I want the description to show up in the page content. Instead of saying search results - not found - I would like it to list the page description on the page itself above any results. How can I do this? I am using the Bel Air template from Gorilla Themes

    Thanks in advance for your help!

  2. stvwlf
    Posted 5 years ago #


    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));

    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>

Topic Closed

This topic has been closed to new replies.

About this Topic