カスタム投稿タイプのメタ ボックスを作成しています。ではなく wysiwyg エディターを使用したいフィールドが複数あります<textarea>
。複数のエディターをメタ ボックスに追加することはできますか?
助けていただければ幸いです。
どうもありがとう。ダーシャ
カスタム投稿タイプのメタ ボックスを作成しています。ではなく wysiwyg エディターを使用したいフィールドが複数あります<textarea>
。複数のエディターをメタ ボックスに追加することはできますか?
助けていただければ幸いです。
どうもありがとう。ダーシャ
http://codex.wordpress.org/Function_Reference/wp_editorは、私が見つけた最も簡単な方法で、Wordpress 3.3 以降に組み込まれています (アップグレードしてください ;-) )
ただし、カスタムテンプレートのテキストエリアにはtoogle JSの問題があり、すべてのタグと改行が削除されるため、プレゼンテーションを nl2br() 関数に置き換える必要があり<P>
ます<br/>
。
// for custom post type
function wo_second_editor($post) {
echo "<h3>Write here your text for the blue box on the right:</h3>";
$content = get_post_meta($post->ID, 'wo_blue_box' , true ) ;
wp_editor( htmlspecialchars_decode($content), 'wo_blue_box', array("media_buttons" => false) );
}
add_action('edit_form_advanced', 'wo_second_editor');
function wo_save_postdata($post_id, $post, $update) {
//...
if (!empty($_POST['wo_blue_box'])) {
$data=htmlspecialchars($_POST['wo_blue_box']);
update_post_meta($post_id, 'wo_blue_box', $data );
}
}
add_action('save_post', 'wo_save_postdata');
// Theme:
<div class="blue">
<?php
$content = get_post_meta(get_the_ID(), 'wo_blue_box' , true );
$content = htmlspecialchars_decode($content);
$content = wpautop( $content );
echo $content;
?>
</div>
次を使用して、メタボックスでワードプレスのデフォルトのテキストエディターを使用できます
add_action( 'edit_page_form', 'my_second_editor' );
function my_second_editor() {
// get and set $content somehow...
wp_editor( $content, 'mysecondeditor' );
}
カスタムフィールドテンプレートプラグインをお試しくださいhttp://wordpress.org/extend/plugins/custom-field-template/