2010-11-18 8 views
1

wp-admin> Appearance> Widgetsのオプションパネルで変更可能なウィジェットのタイトルが必要です。Wordpress Widgetのオプションの保存が機能しません

"SAVE"をクリックしても機能していないようですが、保存する代わりにデフォルトが返されます。

ウィジェットコントロールパネルは非常に単純です:

function myplugin_control() { 

    echo '<p> 
      <label for="myplugin_title">Title:</label> 
      <input id="myplugin_title" name="myplugin_title" type="text" value="Default title:"/> 
     </p> 
     <p> 
      <label for="myplugin_number">Number of items to show:</label> 
      <input id="myplugin_number" name="myplugin_number" type="text" value="5" size="3"/>'; 

     $myplugin_title = ($_POST["myplugin_title"]); 
     $myplugin_number = ($_POST["myplugin_number"]); 

     update_option('myplugin_widget', $myplugin_number , $myplugin_title); 

} 

、プラグインは次のようになります:私はあなたが(にupdate_optionを使用していると思う

(...) 
    function widget_myplugin($args) { 
     extract($args); 
     echo $before_widget; 
     echo $before_title . $myplugin_title . $after_title; 
     myplugin(); 
     echo $after_widget;  
    } 

答えて

0
  1. )。不適切に。それは2つの値しか取らない。 http://codex.wordpress.org/Function_Reference/update_option

  2. タイトルフィールドの名前を単に「タイトル」に変更してみてください。私はWPがこれをデフォルトで探すと思います。 http://wordpress.org/support/topic/how-can-i-set-a-widgets-title-in-for-use-in-the-dashboard

  3. $ _POST ['title']を使用する代わりに、より標準的な$ this-> get_field_id( 'title')を使用してください。エコー$ this-> get_field_name( 'title');

希望します。また、次のリンクが役立つ場合があります。http://wpengineer.com/1023/wordpress-built-a-widget/

関連する問題