Have used the following function countless times to output raw text wrapped in the relevant HTML tags. But all of a sudden, not working?!?
It’s outputting raw text (ie; airbush-line) which I know is basically what do_shortcode will echo. Just that it is no longer running through my custom function?
I have a custom meta field in a CPT, which output raw text, which I would then wrap in my function, so an icon would be displayed, but it’s currently not playing ball?
The meta box code –
$prefix = 'theme_';
$meta_box_service = array(
'id' => 'service_details',
'title' => __( 'Service Details', 'budd' ),
'page' => 'services',
'context' => 'normal',
'priority' => 'high',
'fields' => array(
array(
'name' => __( 'Service Icon', 'budd' ),
'id' => $prefix . 'service_icon',
'type' => 'select',
'options' => array(
'Airbush (Line)' => 'airbrush-line',
'Airbrush (Solid)' => 'airbrush-solid',
'Bar Chart (Solid)' => 'bar-chart-solid'
)
),
array(
'name' => __( 'Service URL', 'budd' ),
'id' => $prefix . 'service_url',
'type' => 'text',
'std' => ''
)
)
);
add_action( 'admin_menu', 'theme_add_box_service' );
The do_shortcode for the front-end –
<?php echo do_shortcode( get_post_meta( $post->ID, 'theme_service_icon', $single = true ) ) ?>
And the function I have already –
class IconsMind {
public function __construct() {
add_action( 'init', array( &$this, 'init' ) );
}
public function init() {
add_shortcode( 'icon', array( $this, 'setup_shortcode' ) );
add_filter( 'widget_text', 'do_shortcode' );
}
public function setup_shortcode( $params ) {
extract( shortcode_atts( array(
'name' => 'icon-airbush-line'
), $params ) );
$icon = '<i class="'.$params['name'].'"></i>';
return $icon;
}
}
new IconsMind();
Any advice, truly appreciated
thanks