2016-08-14 50 views
1

我生成了自定義小部件textarea。簡碼在我生成的小部件textarea中不起作用

正常的文本工作,但是當我把短代碼(如:[contact-form-7 id="538" title="widget_subscription"])在textarea然後簡碼不起作用。

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

我使用此代碼的function.php文件。

print direct shortcode

+0

你能解釋一下你所說的「簡碼不該做什麼工作「 - 你能舉一個例子嗎? – halfer

+0

我使用聯繫表單7,使用訂閱表單部件區域。我生成了自定義小部件textarea。然後使用聯繫表單7訂閱表單簡碼,但這個簡碼打印純文本不是訂閱框。 –

回答

0

我相信你需要這樣的代碼:

/* WP function to add_shortcode support. */ 
add_shortcode('your-shortcode', 'do_shortcode'); 

/* Your callable */ 
function do_shortcode(...) { ... } 
0

只需將此代碼添加到主題functions.php

add_filter('widget_text','do_shortcode');