Support » Theme: Twenty Eleven » Show category description on single post page?

  • craftersuniversity

    (@craftersuniversity)


    Hello all!

    I was wondering if there is any way to show the description of a category a post is associated with, on the post own page? I would like it to appear over the meta data part if possible…

Viewing 5 replies - 1 through 5 (of 5 total)
  • Michael

    (@alchymyth)

    Forum Moderator

    if you haven’t already, start by creating a child theme;
    edit content-single.php in the child theme;
    add the new code after this line <footer class="entry-meta">;

    example:

    <?php foreach( get_the_category() as $cat ) {
      if( $cat_descr = category_description( $cat->term_id ) ) { ?>
        <span class="single-cat-description cat-descr-<?php echo $cat->slug; ?>"><?php echo $cat_descr; ?></span>
      <?php }
    } ?>
    craftersuniversity

    (@craftersuniversity)

    Thanx, that worked beautifully! 🙂

    craftersuniversity

    (@craftersuniversity)

    @alchymyth

    I noticed something, the sub categories ends up below the top categories….i was hoping to have it the other way around so the most relevant category, ie the lowest one, is at the top….possible?

    Also, this is a bit off topic, but i cant seem to create links with target=”_blank”, rel=”nofollow” and so forth in their description… is there any way around this?

    craftersuniversity

    (@craftersuniversity)

    @alchymyth

    Correction, the current listing order is alphabetical, not in order of lowest to highest category. Can this be changed?

    craftersuniversity

    (@craftersuniversity)

    Bump

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Show category description on single post page?’ is closed to new replies.