我正在使用cmb2创建自定义帖子类型,我有一个名为legacy\\u cycle的自定义帖子类型,它有一个名为challenges\\u one的元盒。在此元数据库中,有几个wysiwyg文件。
public function challenges_one_metabox(){
$prefix = \'_challenges_one_\';
$challenges_one_metabox = new_cmb2_box(array(
\'id\' => $prefix . \'metabox\',
\'title\' => \'Challenge 1\',
\'object_types\' => array(\'legacy_cycle\'),
\'context\' => \'normal\',
\'priority\' => \'high\',
\'show_names\' => true
));
$challenges_one_metabox->add_field(array(
\'name\' => \'Challenge\',
\'id\' => $prefix .\'challenge\',
\'type\' => \'wysiwyg\',
\'options\' => array(
\'wpautop\' => true,
\'media_buttons\' => true,
\'textarea_rows\' => 10,
\'quicktags\' => false,
),
));
$challenges_one_metabox->add_field(array(
\'name\' => \'Generate Ideas\',
\'id\' => $prefix .\'generate_ideas\',
\'type\' => \'wysiwyg\',
\'options\' => array(
\'wpautop\' => true,
\'media_buttons\' => true,
\'textarea_rows\' => 10,
\'quicktags\' => false,
),
));
$challenges_one_metabox->add_field(array(
\'name\' => \'Gather Multiple Perspectives\',
\'id\' => $prefix .\'gather_multiple_perspectives\',
\'type\' => \'wysiwyg\',
\'options\' => array(
\'wpautop\' => true,
\'media_buttons\' => true,
\'textarea_rows\' => 10,
\'quicktags\' => false,
),
));
$challenges_one_metabox->add_field(array(
\'name\' => \'Research and Revise\',
\'id\' => $prefix .\'research_and_revise\',
\'type\' => \'wysiwyg\',
\'options\' => array(
\'wpautop\' => true,
\'media_buttons\' => true,
\'textarea_rows\' => 10,
\'quicktags\' => false,
),
));
$challenges_one_metabox->add_field(array(
\'name\' => \'Test Your Mettle\',
\'id\' => $prefix .\'test_your_mettle\',
\'type\' => \'wysiwyg\',
\'options\' => array(
\'wpautop\' => true,
\'media_buttons\' => true,
\'textarea_rows\' => 10,
\'quicktags\' => false,
),
));
$challenges_one_metabox->add_field(array(
\'name\' => \'Go Public\',
\'id\' => $prefix .\'go_public\',
\'type\' => \'wysiwyg\',
\'options\' => array(
\'wpautop\' => true,
\'media_buttons\' => true,
\'textarea_rows\' => 10,
\'quicktags\' => false,
),
));
}
然后,我使用木材作为主题工具来显示输入。
<div role="tabpanel" class="tab-pane" id="challenge1">
<h4> Challenge </h4>
<div>
<p>{{post._challenges_one_challenge}}</p>
</div>
<h4> Generate Ideas </h4>
<div>
<p>{{post._challenges_one_generate_ideas}}</p>
</div>
<h4> Gather Perspectives </h4>
<div>
<p>{{post._challenges_one_gather_multiple_perspectives}}</p>
</div>
<h4> Research & Revise </h4>
<div>
<p>{{post._challenges_one_research_and_revise}}</p>
</div>
<h4>Test Your Mettle</h4>
<div>
<p>{{post._challenges_one_test_your_mettle}}</p>
</div>
<h4> Go Public </h4>
<div>
<p>{{post._challenges_one_go_public}}</p>
</div>
</div>
然而,所见即所得字段无法正常工作。如果它只包含文本或图像就可以了,但当我在所见即所得编辑器中的自定义帖子类型下插入youtube视频时,它只输出以下信息。
“[嵌入]https://www.youtube.com/watch?v=MS91knuzoOA[/embed]“我尝试使用post.get\\u filed(\'my\\u wysiwig\'),但没有成功。
我想知道如何正确输出字段?非常感谢!