Skip to content

Instantly share code, notes, and snippets.

@danielortiz
Created August 12, 2014 21:00
Show Gist options
  • Save danielortiz/61201e430348c304a9a7 to your computer and use it in GitHub Desktop.
Save danielortiz/61201e430348c304a9a7 to your computer and use it in GitHub Desktop.
Prints Post Format icon using Font Awesome in WordPress
if ( ! function_exists( 'prefix_post_format_icon' ) ) :
/**
* Prints HTML with meta information for the current post format using Font Awesome.
*/
function prefix_post_format_icon(){
$icon_string = '<span class="format-icon"><i class="fa %1$s"></i></span>';
if(is_sticky()){
$format_icon_class = 'fa-thumb-tack';
}else{
switch (get_post_format()) {
case "aside":
$format_icon_class = 'fa-quote-plus';
break;
case "image":
$format_icon_class = 'fa-image';
break;
case "video":
$format_icon_class = 'fa-video-camera';
break;
case "quote":
$format_icon_class = 'fa-quote-left';
break;
case "link":
$format_icon_class = 'fa-link';
break;
default:
$format_icon_class = 'fa-file-text-o';
}
}
$icon_string = sprintf($icon_string, $format_icon_class );
echo $icon_string;
}
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment