WordPress.org

Forums

Twenty Eleven
Show category description on single post page? (6 posts)

  1. craftersuniversity
    Member
    Posted 1 year ago #

    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...

  2. alchymyth
    Forum Moderator
    Posted 1 year ago #

    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 }
    } ?>
  3. craftersuniversity
    Member
    Posted 1 year ago #

    Thanx, that worked beautifully! :)

  4. craftersuniversity
    Member
    Posted 1 year ago #

    @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?

  5. craftersuniversity
    Member
    Posted 1 year ago #

    @alchymyth

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

  6. craftersuniversity
    Member
    Posted 1 year ago #

    Bump

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic

Tags

No tags yet.