Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am aware of creating a shortcode this way:

function font_fam($atts, $content = null){ 
extract(shortcode_atts(array(
  '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=")

Thanks!

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

Try this:

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

    extract(shortcode_atts(array(
            '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
add comment

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
add comment

Your Answer

 
discard

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.