Wordpress theming 第二个wordpress编辑器的输出帖子

Wordpress theming 第二个wordpress编辑器的输出帖子,wordpress-theming,Wordpress Theming,我最近用Wordpress 3.3的新功能在我所有的页面和帖子管理区添加了一个新的编辑器 add_action( 'edit_page_form', 'my_second_editor' ); function my_second_editor() { // get and set $content somehow... wp_editor( $content, 'mysecondeditor' ); } 我的问题是如何在我的网站/页面上输出我在第二个编辑器中输入的内容?我需要

我最近用Wordpress 3.3的新功能在我所有的页面和帖子管理区添加了一个新的编辑器

add_action( 'edit_page_form', 'my_second_editor' );
function my_second_editor() {
    // get and set $content somehow...
    wp_editor( $content, 'mysecondeditor' );
}
我的问题是如何在我的网站/页面上输出我在第二个编辑器中输入的内容?我需要做一个自定义循环吗?不幸的是,法典并没有很好的帮助


谢谢

您将需要
获取post\u meta()
,使用方法如下:

echo get_post_meta(get_the_id(), 'mysecondeditor');
阅读更多:

要保存在第二个编辑器中输入的数据,您需要在
functions.php
文件中使用以下代码:

add_action( 'save_post', 'save_post', 10, 2 );
function save_post( $post_id, $post ) {
  if ( !current_user_can( 'edit_post', $post_id ) )
    return $post_id;

  update_post_meta( $post_id, 'mysecondeditor', stripslashes( $_POST['mysecondeditor'] ) );

}
在那之后,他是你的第二个编辑的完整代码:

wp_editor( get_post_meta(get_the_id(), 'mysecondeditor', true), 'mysecondeditor' );
上面的
true
确保只返回一个变量,而不是一个数组,因此您可以立即使用它。

user2019515I的(2013年4月18日12:06)答案对我有效,我可以添加文本和图库,但当我用此代码显示时:

<?php echo get_post_meta(get_the_ID(),'mysecondeditor')['0']; ?>

我怎样才能显示文本(mytext)和图像呢?

hmmmm,这似乎可行,但我的第二个文本编辑器在重新加载页面时似乎丢失了内容,我得到的只是页面上的单词数组,而不是我在第二个编辑器中输入的内容。我需要比jsut更多的代码吗?为了让第二个编辑器工作,我在上面的eaxample中输入了添加操作?我会回答这个问题我只需要先验证是的,要在保存时显示编辑器中的文本,你需要连接到
保存帖子数据
我会更新我的答案对不起,但所做的只是将编辑器放在我网站的前端,以便全世界都能看到它。它仍然不保存任何数据。我错过了什么。我将上面的原始代码保存在函数中,然后像您所说的那样将代码添加到函数中。然后添加了您在上面更改的echo get_post_meta。您的functions.php文件可能还有另一个问题,上面的代码可以工作。好的,我可以用这段代码解决它:因此,我有两个自定义帖子类型的编辑器,我可以通过显示第二个编辑器的图库来分别显示第二个编辑器的内容。
mytext   [gallery ids="102,62"]