WordPress.org

Support

Support » Themes and Templates » [Resolved] Cant seem to display category description in archive.php

[Resolved] Cant seem to display category description in archive.php

  • Hi all,

    I am trying to display a category description in an archive page. The following code will display the category title in my archive page:

    <?php if (have_posts()) { ?>
    					<?php $post = $posts[0]; ?>
    						<h2 class="title">
    							The Archive for
    							<?php
    							if (is_category()) { single_cat_title(); }
    							elseif (is_tag()) { ?>  posts tagged "<?php single_tag_title(); ?>" <? }
    							elseif (is_day()) { the_time('F jS, Y'); }
    							elseif (is_month()) { the_time('F, Y'); }
    							elseif (is_year()) { the_time('Y'); }
    							elseif (is_author()) { the_author(); }
    							 ?>
    						</h2>

    I have tried calling the category_description with no luck. Does anyone know a simple solution?

    Thanks

Viewing 10 replies - 1 through 10 (of 10 total)
  • Did you insert into your code the following:

    echo category_description();

    It should display the current category, or the description from the first category called in a list of categories.

    There are more examples on the codex page here: http://codex.wordpress.org/Template_Tags/category_description

    I know I often forget to ‘echo’ some functions, that’s why I am suggesting it … hope it helps.

    Cool thanks, any idea where abouts?

    Try <?php echo category_description(); ?> right below the </h2>

    Ok just tried that and not seeing any descriptions:

    http://www.magic-photography.co.uk/

    if you click on the ‘recent gigs’ (category list) only a title appears?

    Thanks again

    Sorry, I was inaccurate. You must include the ID for the category:

    <?php echo category_description(ID); ?>

    For example:

    <?php echo category_description(3); ?>

    ya but I dont know what the category is, as I will want this to appear under each unique category,
    So if you click category 1 you see a title and description, categor 2 a different title and description, and so on..

    either way it still did not work putting in a ‘3’ or any number..

    Any ideas anyone?

    At the end of the codex page I linked to there is an example that appears to be what you are looking for …

    … in your code try this:

    <?php
      if (is_category()) { single_cat_title(); echo category_description(); }
      elseif (is_tag()) { ?>  posts tagged "<?php single_tag_title(); ?>" <? }
      elseif (is_day()) { the_time('F jS, Y'); }
      elseif (is_month()) { the_time('F, Y'); }
      elseif (is_year()) { the_time('Y'); }
      elseif (is_author()) { the_author(); }
    ?>

    Although I did not notice the words: “The Archive for” as I would expect, make sure you are editing the correct archive page. This link may help as well: http://codex.wordpress.org/Templates_Hierarchy

    as yes. I removed ‘archive for’ on purpose. Thanks for the help I will give it a go.

    worked perfectly, thanks so much

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘[Resolved] Cant seem to display category description in archive.php’ is closed to new replies.
Skip to toolbar