Add a shortcode in a sidebar widget title


#1

i have one question…
how can u add a shortcode in a sidebar widget title?
i know that for the widget is :


	add_filter( 'widget_text', 'shortcode_unautop');
	add_filter( 'widget_text', 'do_shortcode');

but for the title?


#2

An obvious guess would be widget_title … ?


#3

:)) i did that … it worked :)) stupid me… now another question… how do i register multiple functions, with a for?:slight_smile:


#4

Register multiple functions…?

Can you please show some code? I don’t fully understand, what you want to do :slight_smile:


#5
Register multiple functions..?

Can you please show some code? I don’t fully understand, what you want to do :slight_smile:

hey.


	function icon1() { return '';}
	add_shortcode('icon1','icon1');	
	function icon2() { return '';}
	add_shortcode('icon2','icon2');	
	function icon3() { return '';}
	add_shortcode('icon3','icon3');	
	function icon4() { return '';}
	add_shortcode('icon4','icon4');	

there are alot of icons and i want to do this with a for :smiley: thank you


#6

Hey duotive the next time please write a useful title man not just ‘Hey’, that way your problem can solve others problems :wink:

Cheers.


#7
Hey duotive the next time please write a useful title man not just 'Hey', that way your problem can solve others problems ;)

Cheers.

i was dreaming… can u change the title for me? thanks


#8

Why don’t you use a structure like this:

function icon($atts, $content=null) {
    extract(shortcode_atts(array(
      "type" => ''
    ), $atts));

    return '';

}

and use the types like:

[icon type=“1”]
[icon type=“2”]
[icon type=“3”]

Would be easier and a much cleaner code. :slight_smile: D.R.Y!!! (Don’t repeat yourself)


#9

I’m just replying to say hi.


#10

hi turkhitbox
thanks bebel will try it when at home :x