• I’m trying to display the category description on the category archive pages, but the tag that I found isn’t working.

    I’m using

    <?php /* If this is a category archive */ if (is_category()) { ?>
    <?php category_description(); ?>

    But my description does not appear. Am I doing something wrong?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Took this from the wp-content/themes/default/archive.php template file:
    <h2 class="pagetitle">Archive for the '<?php echo single_cat_title(); ?>' Category</h2>

    Thread Starter redbox

    (@redbox)

    Thanks for the reply. That shows the title, but I’m trying to add the additional description field.

    The page in codex for category descriptions at https://codex.www.ads-software.com/Template_Tags/category_description shows what I attempted, but for some reason it’s not displaying anything.

    Because your code doesn’t “know” which category’s description to display. The Codex page you linked says it has to have a (category) parameter:
    category
    (integer) The numeric category ID for which category description to return. Defaults to current category, if one is set.

    I am not a coder, but I am sure you need to tell/get what the current category is in order to make it work.

    Thread Starter redbox

    (@redbox)

    I tried adding the category code such as (11), but that didn’t do anything either. I also hoped that leaving it blank would cause it to default to the current category. Either way, nothing happened. Has anyone else seen this work?

    Didn’t try this but how about:
    <?php echo category_description(11); ?>

    Thread Starter redbox

    (@redbox)

    That worked perfect, thanks! I added <?php echo category_description(); ?> and it pulls the description for the current category.

    Thank you ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘how to display category descriptions on archive pages?’ is closed to new replies.