WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am aware of creating a shortcode this way:

function font_fam($atts, $content = null){ 
  'f' => '',  
  ), $atts ));

return '<span style="font-family:'.$f.'">'.$content.'</span>';

add_shortcode ('f','font_fam');

And to use it would be like this right:

[f f="Arial"] Text Text [/f]

But is there a way so that it will be used like this:

[f Arial] Text Text[/f]
[f Tahoma] Text Text [/f]

(skipping the "f=")


share|improve this question
up vote 5 down vote accepted

Try this:

function font_fam($atts, $content = null) {

            'f' => isset($atts[0]) ? $atts[0] : '' ,
            ), $atts));

    return '<span style="font-family:' . $f . '">' . $content . '</span>';

add_shortcode ('f','font_fam');
share|improve this answer
Woohoo! It works! Thanks! – John Feb 19 '11 at 13:41

One way could be to preparse your content by hooking a 'the_content' filter that adds the f= bit.

Another could be to change your shortcodes to something like [Tahoma]...[/Tahoma] and skip the f altogether, although then you end up registering a lot of shortcodes.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.