-3

I just create a simple WordPress theme, everything looks fine but when I use a plugins which need shortcode.

I put the short code in a page (like this [user-submitted-pos‌​ts]), on front end, it show same short code. When I change to another theme, the short code works fine.

Shortcode doesn't work, is this need function.php support it?

2

You should add to theme something like this:

add_filter('shortcode_function_name', 'do_shortcode');

This should be enough. Here you can find the documentation related to the shortcodes:

https://developer.wordpress.org/reference/functions/do_shortcode/

2
  • 1
    Perhaps you should explain a bit why this should work, for instance by linking to the place where this filter is defined.
    – cjbj
    Apr 13 '17 at 13:52
  • Modified. this is ok? Apr 13 '17 at 14:15
1

Suggest you look at one of the twenty-x themes to see what's different and read up on using "apply_filters('the_content',....) before outputting the page or post content.

0

If the shortcode is added to the excerpt or widgets areas, then you have to add the following code into the "functions.php" file from your main or child theme folder:

// Adding Shortcodes to the_excerpt() function
add_filter('the_excerpt', 'do_shortcode');

// Enable shortcodes in widgets
add_filter('widget_text', 'do_shortcode');

Not the answer you're looking for? Browse other questions tagged or ask your own question.