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!

2 Answers
2

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');

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *