WordPress.org

Ready to get started?Download WordPress

Forums

how to add icon category every post category ? (2 posts)

  1. hevan
    Member
    Posted 1 year ago #

    i want to added mini icon on imgae post on every category post.

    VIEW THIS DEMO

    please some one can help me ?
    sorry my english very bad.

  2. tylerhq
    Member
    Posted 1 year ago #

    The most simple way of doing this is by checking if a thumbnail exists, and if so, checking that a category is assigned, and if so, adding the icon.

    In the Page Template, you'd have something like this:

    <div class="thumbnailContainer">
      <?php
        if ( has_post_thumbnail() ) {
          the_post_thumbnail();
          $singleCatTitle = single_cat_title("", false);
          if(single_cat_title("", false)){
      ?>
      <img class="thumbnailBannerIcon" src="/path/to/<?php echo $singleCatTitle ?>.png"/>
      <?php
          }
        }
      ?>
    </div>

    Then, by using "position: relative;" on the thumbnail container, and "position: absolute;" on the icon, you can place it in the corner, appropriately.

Topic Closed

This topic has been closed to new replies.

About this Topic