테마 옵션과 해당 작업을 사용하는 것이 좋습니다. 이제 클라이언트는 한 그룹에 두 개의 텍스트 필드를 추가하려고합니다. 나는 그것을 완벽하게 만들지 만 그것은 적절한 데이터를 저장하지 않으며 오직 하나의 값만을 보여줍니다.테마 옵션에 여러 개의 텍스트 필드를 저장하고 표시하는 방법
예를 들면 : 첫 번째 필드에 "Hello"를 쓰고 두 번째 필드에는 "12"를 씁니다. 데이터를 저장하면 두 필드 "12"에 모두 저장됩니다. 여기
내 코드입니다 :case 'text':
default:
echo '<input class="regular-text' . $field_class . '" type="text" id="' . $id . '" name="mytheme_options[' . $id . ']" placeholder="' . $std . '" value="' . esc_attr($options[$id]) . '" />';
if ($desc != '')
echo '<br /><span class="description">' . $desc . '</span>';
break;
case 'multipletext':
default:
echo '<input class="regular-text' . $field_class . '" type="text" id="' . $id . '1" name="mytheme_options[' . $id . ']" placeholder="' . $std . '" value="' . esc_attr($options[$id]) . '" style="width:19.4em !important;" />
<input class="regular-text' . $field_class . '" type="text" id="' . $id . '2" name="mytheme_options[' . $id . ']" placeholder="' . $std . '" value="' . esc_attr($options[$id]) . '" style="width:5em !important;" />';
if ($desc != '')
echo '<br /><span class="description">' . $desc . '</span>';
break;
===============================
$this->settings['distance_from'] = array(
'title' => __('Distance'),
'desc' => __('Enter distance from argus here.'),
'std' => '',
'type' => 'multipletext',
'section' => 'contact'
);
$this->settings['phone'] = array(
'title' => __('Phone Number'),
'desc' => __('Enter phone number here.'),
'std' => '',
'type' => 'text',
'section' => 'contact'
);
처럼 보여주고 싶은,하지만 당신은 같은 이름을 가진 두 개의 필드를 생성하는 경우, 이것은 제출에 사용 된 것입니다. 두 번째'name = "mytheme_options [ '. $ id.']"''를'name = "mytheme_options [ '. $ id.'2]"'(닫는 괄호 앞에'2 ' , 그것은 예상 값 (이드가가는) 인 것으로 보인다. 실패하면 id를 모두 제거하십시오 ('name = "mytheme_options []"'). – Hobo