WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to actally show category description (6 posts)

  1. Ry4nrc
    Member
    Posted 1 year ago #

    Hi everyone

    I have a problem and i have no idea how to make this work, i am trying to add a description to my category pages (not archives) i have searched for about two hours trying to make this work but to no luck.

    I am using the elegant themes, delicate news template and it does not use a archive.php if that helps.

    I have tried the <?php echo category_description( $category_id ); ?> but do not know exactly where it goes and it should be in the archive.php

    Any help would be greatly appreciated. Thanks

  2. Digital Raindrops
    Member
    Posted 1 year ago #

    Does it have a category.php?

    <?php global $cat; ?>
    <?php echo category_description( $cat ); ?>

    If no category.php or archive.php in index.php

    <?php if( is_category() ) : ?>
       <?php global $cat; ?>
       <?php echo category_description( $cat ); ?>
    <?php endif; ?>

    HTH

    David

  3. Ry4nrc
    Member
    Posted 1 year ago #

    Thank you so much that worked a treat.

    I also added

    <!-- category-title -->
    <?php global $post; $category = get_the_category($post->ID); echo $category[0]->name; ?>

    For the category title

    I am trying to style the title and description now as it is very small, i have tried the "Allow HTML in description" plugin and similar ones but that does not work.

    I am wanting the category title to be h1 and the text to be smaller, i have tried linking the new php line to a new class in my ccs file my cannot get it to work.

    You are the man, hope you can help with this one. Thanks

  4. Ry4nrc
    Member
    Posted 1 year ago #

    Oh yes you can see the size of the text Here right under the logo, and for anyone that is having problems with this, i added the code to the index.php

    Just under

    <?php global $query_string;
    			if (is_category()) query_posts($query_string . "&showposts=$post_number&paged=$paged&cat=$cat");
    			else query_posts($query_string . "&showposts=$post_number&paged=$paged"); ?>
  5. Digital Raindrops
    Member
    Posted 1 year ago #

    Hi Rynrc,
    Glad you have it sorted, mark this as resolved please.

    I am wanting the category title to be h1 and the text to be smaller, i have tried linking the new php line to a new class in my ccs file my cannot get it to work

    Have a look at how the current titles are rendered, and get_cat_name($cat), to style the title change the class name and copy and rename an existing style block to your class name.

    <h1 class="cat-title">
    <!-- category-title -->
    <?php global $cat; echo get_cat_name( $cat ); ?>
    </h1>

    Style:

    .entry h1.cat-title {
        color: #757575;
        font-size: 20px;
        margin-bottom: 10px;
    }

    Note:
    As it is a category the WordPress template heirarcy will find the first of category-{$slug}.php, category.php, archive.php and index.php so saving index.php as category.php and making the changes will mean you will not need the is_category() condition and maintain the index.php.

    I recently enchanced the categories to use a custom posts for the description.

    HTH

    David

  6. Ry4nrc
    Member
    Posted 1 year ago #

    Thank you David, all is well now.

    Thanks for all the great help!

Topic Closed

This topic has been closed to new replies.

About this Topic