Site logo

Archived topic

Show icon in widget title

9 replies · Started by Orlando on February 22, 2018

Viewing posts 1–10 of 10

Hi,

I'm trying to show a Font Awesome icon in widget title; so far I tried enabling shortcode support for widgets, but that didn't work - it doesn't show anything...however, it works without GP.

So, is there any way to acomplish this?

TIA

Hi there,

It's probably because we are still in the process of upgrading to FontAwesome 5.0.

What's the HTML you are using for the icons?

Let me know.

Hi Leo,

Here's all I tried; I made a small plugin with this code:

add_filter('widget_title', 'do_shortcode');

function hcwp_add_icon_widget($attr) {
	// Atributos
	$attr = shortcode_atts(
		array (
			'id' => 'star',
		), $attr, 'icon'  );
		
	return '<i class="fa fa-'.$attr['id'].'"></i>';
}

add_shortcode( 'icon', 'hcwp_add_icon_widget');

Then I prepend the icon to the widget title with a shortcode, i.e. [icon id=star], when processed it generates "<i class="fa fa-star"></i>" in the code...and it worked fine on a local setup without GP, but when I uploaded it didn't show anything.

Thanks in advance.

Hi,

No, it's not.

Does anything show up at all? Can you link me to your site?

Hi,

Oh dear...it's working now. Sorry to bother you. Anyway, page is http://www.hazloconwp.com.mx.

Thank you for your time and excellent theme!

Glad you figured out!

is there a way to do this without the extra function yet? i need to add a icon to a Widget Nav Title in the footer widgets?

It was never a plan to add this as a feature.

Can you open a new topic for your question?

Depending on where you are trying to (at the start?), there might be a CSS solution.

Thanks!

This archived topic is closed to new replies.