Skip to content

Snippet: Alter The Post Format Icons

The Post with Icons widget and other theme functions may display an icon based on the current post format. You can easily filter the format icon classname using a filter like in the example above. You can refer to the Theme Icons list for the correct classname or use your own classname to target via CSS or a 3rd party icon set.

 * Alter The Post Format Icons.
 * @link
add_filter( 'wpex_post_format_icon', function() {
	$format = get_post_format() ?: 'post';

	switch ( $format ) {
		case 'video':
			$icon = 'ticon ticon-video-camera';
		case 'audio':
			$icon = 'ticon ticon-music';
		case 'gallery':
			$icon = 'ticon ticon-file-photo-o';
		case 'quote':
			$icon = 'ticon ticon-quote-left';
			$icon = 'ticon ticon-file-text-o';

	return $icon;
} );
All PHP snippets should be added via child theme's functions.php file or via a plugin. We recommend Code Snippets (100% Free) or WPCode (sponsored)
Back To Top