• Hello together,
    i had found out some weeks ago that i can give every category its own discription.
    Just Edit the normal Category, fill out the Description field, post the code
    <?php echo category_description(); ?>
    at the place you like to have the description and be happy.

    So i thought it would be easily done. I wrote for every Category a unique explaining description for my visitors and i wanted to put the description at the top of all posts for each category.

    So it looked now like this in the index.php:

    <div id="content">
    <div style="padding: 0 10px 5px 10px;"><?php echo category_description(); ?></div>
    <div class="main_title">

    Somehow i hoped that the default category would be the home-site, but it woulnd’t be such a downer if i am wrong in it. But that it shows NOTHING at all makes it kind of bad.

    I do find these Description Texts now as a hovereffect when i place the mous on the Category in my sidebar.

    Is there now any way to get the Description shown atop of my Postings and, as a nice sidecandy ;), that i can disable the discription hover in the sidebar?

    The Sidebar is really not important, but i would be glad if i get the Discription shown when someone choose only this category.

    Kind Regards

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter caylean

    (@caylean)

    [ http://codex.wordpress.org/Forum_Welcome#No_Bumping ]

    Nobody any ideo or is my question that stupid and easy to answer that it should be solved by myself already 😉

    Say like that, i found several instructions and also the codex was checked for it, but whatever i do, there is no shown description when i place it in the index.php

    Actually its not that easy :). I think you need to define the category ID.

    <? $cat_id = get_the_category(); echo category_description($cat_id); ?>

    But anyway, I am not 100% sure if the code would work if its added in the index.php. If it will not maybe try adding it to the category.php

    http://codex.wordpress.org/Function_Reference/category_description

    building on the suggestion by @MegaToon Tv:

    <?php $cat_id = get_the_category(); echo category_description($cat_id[0]->term_id); ?>

    http://codex.wordpress.org/Function_Reference/get_the_category

    Thread Starter caylean

    (@caylean)

    Thanks for your Help, but as far as i tested it, it isn’t function 🙁

    @MegaToon TV, i do not have an category.php in the Template

    @Slchymyth, Your Code isn’t function. I have placed it where i did it always before and there is nothing shown.
    (The Place is fine, i had tested it already with a static Text and it was shown where I wanted to have the description. Also is the Code not to be found in the Sourcecode of the complete loaded Blog.)

    index.php:

    <div id="content">
    <div style="padding: 0 10px 5px 10px;"><?php $cat_id = get_the_category(); echo category_description($cat_id[0]->term_id); ?></div>
    <div class="main_title">

    Sourcecode on loaded site:

    </div>
    <div id="content">
    
    <div class="main_title">

    To me it seems strange. You can add such a ‘wonderful’ thing to your categories to make them more attractive, but there isn’t an easy way to do so.
    Shouldn’t be there somewhere a marker or something that tells already “Hey, you are in Category 7” so that <?php echo category_description(); ?> could get the needed information without any complications?

    Thread Starter caylean

    (@caylean)

    I just digged out an old post from 4 years ago
    http://en.forums.wordpress.com/topic/showhide-category-descriptions

    As far as the author said what i am doing was once fine. Was there maybe such a major change in the code that this function was deleted, overseen or something?

    Maybe kind of buggy?

    Thread Starter caylean

    (@caylean)

    Stupid me!
    The index.php is really just for the / page.
    If i go now into an Category the achive.php file is in charge!

    Everybody, everywhere you read that you have to put it into the achive.php file, but somehow i was so sure that it always meant something different.
    Now it is function as it should be.
    <? $cat_id = get_the_category(); echo category_description($cat_id); ?>
    IS function, BUT
    <?php echo category_description(); ?>
    is function TOO.

    Thank you very very much. Now i just have to complete my descriptions and it is all really nice and smooth 🙂

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘echo category_description not working in index.php?’ is closed to new replies.