WordPress – trying to create shortcode

I’m trying to do shortcode with default attributes.

Here’s my code:

function custom_list_item_shortcode($attributes, $content = null ) {

extract( shortcode_atts( array(
    'icon' => '',
    'color' => ''
), $attributes ) );

$html = '<div class="listbox-item">';

//--If there is an icon show icon
if($icon != ''){
    $html .=  '<div class="listbox-icon"><i class="fa fa-'.$icon.' icon-'.$color.'"></i></div>';

$html .=  '<div class="listbox-content">'.$content.'</div>';
$html .= '</div>';
return  $html;
add_shortcode('icon-list', 'custom_list_item_shortcode');

What I want to achieve is that some things (for example font size etc.) are default and class is not displayed in firebug, but when someone wants to change font size, they can just type

[icon-list icon="globe" size="22"][/icon-list]

Any ideas?

Source: shortcode

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.