2
我遇到了WordPress元框的問題。實際上,我使用的是WordPress Genesis框架,在兒童主題中,我爲客戶創建了幾個元框,以在頁面內容之前顯示一些內容,但是在自定義元框中,我使用的是wp-editor,並且其工作正常。但問題是,當我嘗試在這個WP編輯器中使用一些簡碼時,它不會顯示任何內容,它只是按原樣返回整個簡碼。短代碼不能在定製metabox中工作
我正在使用https://github.com/jaredatch/Custom-Metaboxes-and-Fields-for-WordPress來定製元框。
我的代碼是function.php文件:
/* -------------------------------------------------------------------------- */
/* Setup Custom metaboxes */
/* -------------------------------------------------------------------------- */
add_action('init', 'be_initialize_cmb_meta_boxes', 9999);
function be_initialize_cmb_meta_boxes() {
if (!class_exists('cmb_Meta_Box')) {
require_once(CHILD_DIR . '/lib/metabox/init.php');
}
}
add_filter('cmb_meta_boxes', 'cmb_sample_metaboxes');
function cmb_sample_metaboxes(array $meta_boxes) {
// Start with an underscore to hide fields from custom fields list
$prefix = '_cmb_';
$meta_boxes[] = array(
'id' => 'text_content',
'title' => 'Text Content',
'pages' => array('page',), // Post type
'context' => 'normal',
'priority' => 'high',
'show_names' => true, // Show field names on the left
'fields' => array(
array(
'name' => 'Custom Content',
'desc' => 'This is a title description',
'id' => $prefix . 'custom_content',
'type' => 'title',
),
array(
'name' => 'Tab Name',
'desc' => 'Please descibe the tab name (required)',
'id' => $prefix . 'tab_name',
'type' => 'text',
),
array(
'name' => 'Test wysiwyg',
'desc' => 'field description (optional)',
'id' => $prefix . 'test_wysiwyg',
'type' => 'wysiwyg',
'options' => array('textarea_rows' => 5,),
),
),
);
return $meta_boxes;
}
我保存代碼在page.php文件爲:
add_action('genesis_before_loop', 'ehline_before_loop_content');
function ehline_before_loop_content()
{
echo genesis_get_custom_field('_cmb_tab_name');
echo '<br />';
echo genesis_get_custom_field('_cmb_test_wysiwyg');
}
genesis();
但是,當我使用簡碼在此元框它返回類似的東西
[wptabtitle] Tab 01[/wptabtitle] [wptabcontent]test[/wptabcontent]
請任何人告訴我如何使它在WP編輯器中使用短代碼。
非常感謝。它真的很有幫助。 –