問題描述

我使用 bbPress 2x 並修改了外掛,以使用新的 wp_editor 代替 textarea 來新增新的主題和回覆。這部分精美。

當我被卡住的地方是當一個人點選主題或回覆的編輯。帖子內容沒有顯示在編輯器中。

我可能只是錯過了一些非常愚蠢的東西,希望有人能夠在如何解決這件最後一件事情上發揮作用。

這是我使用的:

$tabindex = bbp_get_tab_index();
$settings = array(
    'wpautop' => true,
    'media_buttons' => true,
    'editor_class' => 'tumble',
    'tabindex' => $tabindex
);

wp_editor( '', 'bbp_topic_content', $settings );

謝謝

編輯

只是回答我的問題,它的工作很好

謝謝你出來:http://soderlind.no/archives/2011/09/25/front-end-editor-in-wordpress-3-3/#comment-207831

$post = get_post($post_id, 'OBJECT');
wp_editor(esc_html($post->post_content), 'textarea01', $settings);

最佳解決方案

為了完整起見,我將根據您在問題中編輯的解決方案發布答案​​。

$post = get_post( $post_id, 'OBJECT' );
wp_editor( esc_html( $post->post_content ), 'textarea01', $settings );

這樣做會逃避 HTML,所以如果你正在編輯一個帖子,你可能想要替換最後一行:

wp_editor( $post->post_content, 'textarea01', $settings );

參考文獻

注:本文內容整合自 Google/Baidu/Bing 輔助翻譯的英文資料結果。如果您對結果不滿意,可以加入我們改善翻譯效果:薇曉朵技術論壇。