上記の通りです。
こちらで作成したwordpressのカスタムフィールドテキストエリアに
テキストエリアに埋め込みコードをペーストしても表示される方法はないでしょうか?
よろしくお願いいたします。
functions.php
PHP
1add_action( 'admin_menu', 'add_custom_field' ); 2function add_custom_field() { 3 add_meta_box( 'custom-map_detail', '地図', 'create_map_detail', 'post', 'normal' ); 4} 5 6function create_map_detail() { 7 $keyname = 'map_detail'; 8 global $post; 9 $get_value = get_post_meta( $post->ID, $keyname, true ); 10 wp_nonce_field( 'action-' . $keyname, 'nonce-' . $keyname ); 11 echo '<textarea style="width: 100%;height: 150px;" name="' . $keyname . '">' . $get_value . '</textarea>'; 12} 13 14add_action( 'save_post', 'save_custom_field' ); 15function save_custom_field( $post_id ) { 16 $custom_fields = ['map_detail']; 17 18 foreach( $custom_fields as $d ) { 19 if ( isset( $_POST['nonce-' . $d] ) && $_POST['nonce-' . $d] ) { 20 if( check_admin_referer( 'action-' . $d, 'nonce-' . $d ) ) { 21 22 if( isset( $_POST[$d] ) && $_POST[$d] ) { 23 update_post_meta( $post_id, $d, $_POST[$d] ); 24 } else { 25 delete_post_meta( $post_id, $d, get_post_meta( $post_id, $d, true ) ); 26 } 27 } 28 } 29 30 } 31}
single.php
PHP
1<?php 2// カスタムフィールドの値を取得 3$map_detail = apply_filters('the_content',get_post_meta($post->ID, 'map_detail', true)); 4?> 5<p><?php echo wp_kses_post($map_detail); ?></p> 6

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/04/15 02:05