1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to show image in category description

Discussion in 'WordPress' started by Divvy, Mar 19, 2016.

  1. #1
    Hello guys,

    Can someone please give me a little help here?

    So I need to show a image in my category description, I already did that but only appears the text and not the html image code.

    Screenshot:
    [​IMG]

    This is my code:
    
    <?php if(is_category()): ?>
                <h1 class="title archive-category"><?php atom()->term->Title(); ?></h1>
    
                <?php if(atom()->term->getDescription()): ?>
                <div class="large">
    
    
                  <p><em><?php atom()->term->Description(); ?></em></p>
    
                </div>
                <div class="divider"></div>
                <?php endif; ?>         
    
                <?php elseif(is_tag()): ?>
    
    PHP:
    I checked Twenty Eleven theme code and inserted this code:
    
    <?php
    $category_description = category_description();
    if ( ! empty( $category_description ) ) {
    echo apply_filters( 'category_archive_meta', '<div class="category-archive-meta">' . $category_description . '</div>' );
    }
    ?>
    
    PHP:
    And works great!! But the problem is that I have duplicated descriptions now and I dont know what to do to solve it.

    Screenshot:
    [​IMG]

    My code with the change:

    
    <?php if(is_category()): ?>
                <h1 class="title archive-category"><?php atom()->term->Title(); ?></h1>
    
                <?php if(atom()->term->getDescription()): ?>
                <div class="large">
    <?php
    $category_description = category_description();
    if ( ! empty( $category_description ) ) {
    echo apply_filters( 'category_archive_meta', '<div class="category-archive-meta">' . $category_description . '</div>' );
    }
    ?>
                  <p><em><?php atom()->term->Description(); ?></em></p>
    
                </div>
                <div class="divider"></div>
                <?php endif; ?>         
    
                <?php elseif(is_tag()): ?>
    PHP:
    What I am doing wrong?
    Can someone help me with this?

    I already tried to remove:
    <p><em><?php atom()->term->Description(); ?></em></p>
    PHP:
    But it gives me an error...

    Full code:
    http://paste2.org/pX8m1KKM

    Hope someone can help me, thanks! :)
     
    Divvy, Mar 19, 2016 IP
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    Seriously... maybe you should read up a _little_ bit before trying to modify code you obviously don't understand. Remove the following lines:
    
    <?php if(atom()->term->getDescription()): ?>
    <p><em><?php atom()->term->Description(); ?></em></p>
    <?php endif; ?>
    
    PHP:
     
    PoPSiCLe, Mar 20, 2016 IP
    Divvy likes this.
  3. Divvy

    Divvy Well-Known Member

    Messages:
    781
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #3
    Thank you buddy, worked fine :)
     
    Divvy, Mar 20, 2016 IP