• Resolved defade

    (@defade)


    Hi…

    I’ve made some custom taxonomies.. just basic tag clouds for specifics topics on my blog

    I then have made a taxonomy.php template page to show a list of posts connected to each custom tag

    Some of these custom tags will have descriptions, but a lot of them won’t

    I’d like to display the descriptions at the top of taxonomy.php pages

    This is easily achieved using this code i found via Google

    <?php echo term_description( '', get_query_var( 'taxonomy' ) ); ?>

    The problem with that code alone is it just prints the description in a basic paragraph

    I need to style the description to make it look pretty etc

    At the moment i have simply wrapped the php code in a div like this

    <div class="tag-desc"><?php echo term_description( '', get_query_var( 'taxonomy' ) ); ?></div>

    This looks perfect when there IS a description for a tag, as can be seen here: Tag with description example

    But this has an unfortunate side effect when you look at a tag with NO description, as seen here: Tag with NO description example (It leaves that horrible looking empty thin black box at the top of the page)

    Could someone that knows coding please tell me how i could call a description nested within a DIV only when there IS a description… and not show the DIV when there is NO description

    I’m sure it must be possible… but i cannot find any help for this

    Many thanks for reading

    -ADE

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    Maybe this will work:

    <?php
    $termDiscription = term_description( '', get_query_var( 'taxonomy' ) );
    if($termDiscription != '') : ?>
    <div class="tag-desc"><?php echo $termDiscription; ?></div>
    <?php endif; ?>
    Thread Starter defade

    (@defade)

    You sir… are a legend

    It works perfectly – Thank you very much

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How do i show a custom-taxonomy description in a DIV only when there is a descri’ is closed to new replies.