Australia's Leading Digital Marketing Experts. T. 1300 235 433  |  Aggregation Enquires Welcome

Example Interest Rates: Home Loan Variable: 1.89% (1.9%*) • Home Loan Fixed: 1.84% (2.11%*) • Fixed: 1.84% (2.11%*) • Variable: 1.89% (1.9%*) • Investment IO: 2.05% (4.36%*) • Investment PI: 1.58% (2.72%*)

Add Style to Text with WordPress Shortcode

The following shortcode is a handy function that will allow you to add text styling using a BBcode (shortcode) style of syntax. You'll easily be able to add CSS styles within your post. Example: [format style="font-size:1.5em;color:#f00;"]Important![/format].

Copy and paste the WordPress function into your theme's functions.php file or, if you sensibly have one installed, your custom functions plugin.

1
<?php 
2
/*
3
 Add Style to Text with WordPress Shortcode
4
 http://www.beliefmedia.com/code/wp-snippets/text-style
5
*/
6
 
7
function beliefmedia_style_text($atts, $content = null) {
8
 extract(shortcode_atts(array(
9
  'style' => ''
10
 ), $atts));
11
 
12
 return '<span' . ($style == '' ? '' : " style=\"$style\"") . ">$content</span>";
13
}
14
add_shortcode('format', 'beliefmedia_style_text');

If you require shortcode to work in a sidebar widget, you'll have to enable the functionality with a filter. If you're using our custom functions plugin, you'll have that feature enabled by default.

Download our 650-page guide on Finance Marketing. We'll show you exactly how we generate Billions in volume for our clients.

  AUS Eastern Standard Time (Washington)

  Want to have a chat?
 

Like this article?

Share on facebook
Share on Facebook
Share on twitter
Share on Twitter
Share on linkedin
Share on Linkdin
Share on pinterest
Share on Pinterest

Leave a comment