WordPress メタボックスに問題があります。実際、私は WordPress Genesis フレームワークを使用しており、子テーマではクライアントがページ コンテンツの前にいくつかのコンテンツを表示するためのメタ ボックスをいくつか作成していましたが、カスタム メタ ボックスでは wp-editor を使用しており、正常に動作しています。しかし、問題は、この wp-editor でいくつかのショートコードを使用しようとすると、何も表示されず、ショートコード全体がそのまま返されることです。
カスタム メタ ボックスに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-editor でショートコードを使用する方法を教えてください。