Snippets: 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.

add_filter( 'wpex_post_format_icon', function() {

	$format = get_post_format();

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

	return $icon;

} );

Snippet Type: PHP

All PHP snippets should be added via a child theme's functions.php file or via the Code Snippets Plugin (or alternative plugin)