Title: show post-format icon for posts in loop
Last modified: August 30, 2016

---

# show post-format icon for posts in loop

 *  Resolved [draig](https://wordpress.org/support/users/draig/)
 * (@draig)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/show-post-format-icon-for-posts-in-loop/)
 * I have a loop that list my posts. I am using post formats and I want to show 
   the correct icon for each post (audio, video, gallery, quote and standard) in
   the loop.
 * [https://wordpress.org/plugins/custom-content-shortcode/](https://wordpress.org/plugins/custom-content-shortcode/)

Viewing 10 replies - 1 through 10 (of 10 total)

 *  Plugin Author [Eliot Akira](https://wordpress.org/support/users/miyarakira/)
 * (@miyarakira)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/show-post-format-icon-for-posts-in-loop/#post-6440507)
 * I looked into this, and added a couple new parameters for `[field]` and `[if]`
   to display/check current post’s post format.
 *     ```
       Post format slug: [field post-format]
       Post format label: [field post-format-name]
       Post format label with link to archive: [field post-format-link]
   
       [if format]
         Post has post format.
       [else]
         Post has no post format.
       [/if]
   
       [if format=audio]
         Post has audio post format.
       [/if]
       ```
   
 * However, there was no easy way to support icons. This is because it depends on
   the theme if and what icons are loaded on the frontend. A couple ideas:
 * 1) If the theme loads icon fonts, you can manually display them for each post
   format. You’ll have to figure out how to display them and which icons would be
   appropriate.
 *     ```
       [if format=audio]
         <i class="icon-audio"></i>
       [/if]
       ```
   
 * 2) Or, you can include icon fonts/images in the theme yourself, then display 
   them.
 *     ```
       [if format=audio]
         <img src="[url theme]/image/post-format/audio.png">
       [/if]
   
       ..or..
   
       <img src="[url theme]/image/post-format/[field post-format].png">
       ```
   
 *  Thread Starter [draig](https://wordpress.org/support/users/draig/)
 * (@draig)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/show-post-format-icon-for-posts-in-loop/#post-6440508)
 * Hi,
 * Thanks for the swift reply and changes. My theme already has post-format icons
   and displays them on the regular blog page.
 * my problem now is that the shortcodes don’t work within the <img> tag
 * <img src=”[url theme]/images/post-formats/[field post-format].png”>
 * Viewing page source this is exactly how it displays.
 *  Plugin Author [Eliot Akira](https://wordpress.org/support/users/miyarakira/)
 * (@miyarakira)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/show-post-format-icon-for-posts-in-loop/#post-6440509)
 * Are the shortcodes inside a post or in a template?
 * —
 * If the theme has post format icons, then it’s matter of figuring out how they’re
   displayed and reproduce the syntax.
 *  Thread Starter [draig](https://wordpress.org/support/users/draig/)
 * (@draig)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/show-post-format-icon-for-posts-in-loop/#post-6440510)
 * They are in a post… well, a page that is listing a loop of posts
 *  Plugin Author [Eliot Akira](https://wordpress.org/support/users/miyarakira/)
 * (@miyarakira)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/show-post-format-icon-for-posts-in-loop/#post-6440511)
 * Hmm..if it’s in a post, then shortcodes should be processed by _the\_content_
   filter. I tested this on my end, and the shortcodes are being run. Is the page
   displayed in a non-standard way somehow..?
 *  Thread Starter [draig](https://wordpress.org/support/users/draig/)
 * (@draig)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/show-post-format-icon-for-posts-in-loop/#post-6440513)
 * It is a close to fresh install of Dynamik Website Builder which is a Genesis 
   child theme.
 * All the shortcodes on the page work fine except if I put a shortcode inside an
   <img> or `<a>` tag… then they do not render.
 *  Plugin Author [Eliot Akira](https://wordpress.org/support/users/miyarakira/)
 * (@miyarakira)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/show-post-format-icon-for-posts-in-loop/#post-6440523)
 * I see, the page builder is filtering the post content differently.
 * I just made a plugin update, please try the following:
 *     ```
       [image][url theme]/image/post-format/[field post-format].png[/image]
       ```
   
 * This is assuming that you have icon images in the specified location.
 *  Thread Starter [draig](https://wordpress.org/support/users/draig/)
 * (@draig)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/show-post-format-icon-for-posts-in-loop/#post-6440567)
 * I discovered that the standard post-format is blank. [field post-format] only
   returns a value for other formats, not the standard one.
 * Here is what I ended up with that works for all post formats.
 * `[if field=post-format][image][url child]/images/post-formats/[field post-format].
   png[/image][else][image][url child]/images/post-formats/default.png[/image][/
   if]`
 * Thanks for your remarkable customer support.
 *  Plugin Author [Eliot Akira](https://wordpress.org/support/users/miyarakira/)
 * (@miyarakira)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/show-post-format-icon-for-posts-in-loop/#post-6440587)
 * I’m glad to hear we solved it. 🙂
 * Just for fun, here’s another variation:
 * `[image][url child]/images/post-formats/[if format][field post-format][else]default[/
   if].png[/image]`
 *  Thread Starter [draig](https://wordpress.org/support/users/draig/)
 * (@draig)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/show-post-format-icon-for-posts-in-loop/#post-6440662)
 * That is more elegant 🙂
 * and it works too!

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘show post-format icon for posts in loop’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/custom-content-shortcode_766976.svg)
 * [Custom Content Shortcode](https://wordpress.org/plugins/custom-content-shortcode/)
 * [Support Threads](https://wordpress.org/support/plugin/custom-content-shortcode/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-content-shortcode/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-content-shortcode/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-content-shortcode/reviews/)

 * 10 replies
 * 2 participants
 * Last reply from: [draig](https://wordpress.org/support/users/draig/)
 * Last activity: [10 years, 10 months ago](https://wordpress.org/support/topic/show-post-format-icon-for-posts-in-loop/#post-6440662)
 * Status: resolved