WordPress.org

Support

Support » Themes and Templates » how to add icon category every post category ?

how to add icon category every post category ?

Viewing 1 replies (of 1 total)
  • 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.

Viewing 1 replies (of 1 total)
  • The topic ‘how to add icon category every post category ?’ is closed to new replies.
Skip to toolbar