2014-04-23 5 views
0

테마 옵션과 해당 작업을 사용하는 것이 좋습니다. 이제 클라이언트는 한 그룹에 두 개의 텍스트 필드를 추가하려고합니다. 나는 그것을 완벽하게 만들지 만 그것은 적절한 데이터를 저장하지 않으며 오직 하나의 값만을 보여줍니다.테마 옵션에 여러 개의 텍스트 필드를 저장하고 표시하는 방법

예를 들면 : 첫 번째 필드에 "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' 
    ); 
+0

처럼 보여주고 싶은,하지만 당신은 같은 이름을 가진 두 개의 필드를 생성하는 경우, 이것은 제출에 사용 된 것입니다. 두 번째'name = "mytheme_options [ '. $ id.']"''를'name = "mytheme_options [ '. $ id.'2]"'(닫는 괄호 앞에'2 ' , 그것은 예상 값 (이드가가는) 인 것으로 보인다. 실패하면 id를 모두 제거하십시오 ('name = "mytheme_options []"'). – Hobo

답변

0

는 또한 value 속성

case 'multipletext': 
    default: 
      echo '<input class="regular-text' . $field_class . '" type="text" id="' . $id . '1" name="mytheme_options[' . $id . '1]" placeholder="' . $std . '" value="' . esc_attr($options[$id.'1']) . '" style="width:19.4em !important;" /> 

     <input class="regular-text' . $field_class . '" type="text" id="' . $id . '2" name="mytheme_options[' . $id . '2]" placeholder="' . $std . '" value="' . esc_attr($options[$id.'2']) . '" style="width:5em !important;" />'; 

      if ($desc != '') 
     echo '<br /><span class="description">' . $desc . '</span>'; 

break; 

에 숫자를 추가하고 쓰기 multipletext 들어 본 적이이

<?php echo mytheme_option('distance_from1'); ?> 
<?php echo mytheme_option('distance_from2'); ?> 
+0

고맙습니다 deemi 다시 한번 내 하루를 저장 – Nadeem

0

플러그인을 사용하여 여러 텍스트 입력란을 사용합니다. Trendwork에서 여러 개의 콘텐츠 블록이라고합니다. 모든 텍스트 부분에 코드를 사용하고 div로 texptblock을 배치 할 수 있습니다. 예컨대 :

<div id="text1">      
<div class=”block_header”> 
<?php the_block('text1'); ?> 
</div></div> 

당신이 디자인하는 고객뿐만 아니라 텍스트를 변경하는 경우에 매우 편리합니다.

+0

아니 부탁이 무슨 물어 ... 제대로 질문을 참조하십시오 – Nadeem

관련 문제