質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
WordPress

WordPressは、PHPで開発されているオープンソースのブログソフトウェアです。データベース管理システムにはMySQLを用いています。フリーのブログソフトウェアの中では最も人気が高く、PHPとHTMLを使って簡単にテンプレートをカスタマイズすることができます。

Q&A

解決済

1回答

2670閲覧

【WP】update_optionが上手く動きません。

matometaru

総合スコア43

WordPress

WordPressは、PHPで開発されているオープンソースのブログソフトウェアです。データベース管理システムにはMySQLを用いています。フリーのブログソフトウェアの中では最も人気が高く、PHPとHTMLを使って簡単にテンプレートをカスタマイズすることができます。

0グッド

0クリップ

投稿2017/02/07 16:46

URL、コードは以下の通りなのですが、保存時に一般設定の画面へ飛ばされ保存できません。どこが間違っていますか?

保存時のURL
options-general.php?wp_star%5Bpage%5D=1&save=変更を保存

保存箇所のコード

PHP

1 2 function admin_setting_form() { 3 $post_types = wp_list_filter( get_post_types(array('public'=>true)),array('attachment'), 'NOT' ); 4 ?> 5 <div class="wrap"> 6 <h2>Fivestar &raquo; <?php _e('Settings'); ?></h2> 7 <form id="<?php echo $this->text_domain; ?>" metho="post" action=""> 8 <?php //wp_nonce_field( 'fivestar-nonce-key', $this->text_domain ); ?> 9 <strong><?php _e('Enable on PostType'); ?></strong> 10 <?php 11 foreach ( $post_types as $post_type ) { 12 ?> 13 <p> 14 <strong><?php echo $post_type; ?>ページ上で有効にします</strong> 15 <input type="checkbox" name="<?php echo $this->text_domain; ?>[<?php echo $post_type; ?>]" value="1" <?php if( $this->text_domain[$post_type] == '1' ) echo 'checked'; ?> /> 16 </p> 17 <?php 18 } 19 ?> 20 </p> 21 <p class="submit"> 22 <input class="button-primary" type="submit" name='save' value='<?php _e('Save Changes') ?>' /> 23 </p> 24 </form> 25 </div> 26 <?php 27 } 28 // save 29 function admin_save_options() { 30 //if( checke_admin_referer( 'fivestar-nonce-key', $this->text_domain ) ) { 31 var_dump( $_POST[$this->text_domain] ); 32 if (isset($_POST['save'])) { 33 if (isset($_POST[$this->text_domain])) { 34 update_option($this->text_domain, $_POST[$this->text_domain]); 35 } 36 $this->message = __('Settings Updated.', $this->text_domain); 37 } 38 $this->options = get_option($this->text_domain); 39 40 update_option( $this->text_domain, $_POST[$this->text_domain] ); 41 $this->admin_setting_form(); 42 //wp_sage_redirect( menu_page_url( $this->text_domain, false ) ); 43 //} 44 }

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

methodのところ、コピペミスでしょうか?

PHP

1<form id="<?php echo $this->text_domain; ?>" metho="post" action="">

投稿2017/02/08 13:44

退会済みユーザー

退会済みユーザー

総合スコア0

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

matometaru

2017/02/08 14:24

記述ミスっていました!! 大変助かりました! ありがとうございます!!!!
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問