Support

Home Forums Event Espresso Premium Cannot show shortcodes in widget

Cannot show shortcodes in widget

Posted: January 12, 2017 at 12:21 pm

Viewing 1 reply thread


wegAdmin

January 12, 2017 at 12:21 pm

My site-specific plugin includes this code:

add_shortcode('field', 'shortcode_field');
function shortcode_field($atts){
	extract(shortcode_atts(array('post_id' => NULL,), $atts));  
	if(!isset($atts[0])) return;
	$field = esc_attr($atts[0]);  
	global $post;  
	$post_id = (NULL === $post_id) ? $post->ID : $post_id;  
	return get_post_meta($post_id, $field, true);
}

But I cannot make shortcodes work inside widgets. What shows up is just the text of the shortcode.


Josh

  • Support Staff

January 12, 2017 at 12:28 pm

Hi Bob,

You’ll find more information about that here:

http://www.wpbeginner.com/wp-tutorials/how-to-use-shortcodes-in-your-wordpress-sidebar-widgets/

Viewing 1 reply thread

The support post ‘Cannot show shortcodes in widget’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso