前提・実現したいこと
Wordpress(バージョン 4.9.8)を使用していています。
詳細ページで投稿日など(年/月/日/記事タイトル)を取得して、お問い合わせページにそれらの値をpostしているのに、年(year)が2018以外の時に404エラーになってしまいます。
テーマはオリジナルです。
未来投稿を有効にしています。
エラーメッセージは無し。。
該当のソースコード
詳細ページの該当部分は以下です。
MAILをクリックして、/reserve/に値を渡しています。
php
1<form method="get" name="form1" action="/reserve/"> 2 <input type="hidden" name="year" value="<?php the_time('Y'); ?>"> 3 <input type="hidden" name="month" value="<?php the_time('n'); ?>"> 4 <input type="hidden" name="date" value="<?php the_time('d'); ?>"> 5 <input type="hidden" name="event" value="<?php echo get_the_title(); ?>"> 6 <a href="javascript:form1.submit()">MAIL</a> 7</form>
受け取るページ(/reserve/:お問い合わせページ)の該当部分は以下です。
php
1$year = $_POST["year"]; 2if($year == '') { 3 $year = mb_convert_encoding($_REQUEST["year"],"UTF-8"); 4} 5 6(中略) 7 8<select name="year" id="elem10"> 9 <option value="2018" <?= $year == '2018' ? 'selected' : "" ?>>2018</option> 10 <option value="2019" <?= $year == '2019' ? 'selected' : "" ?>>2019</option> 11 <option value="2020" <?= $year == '2020' ? 'selected' : "" ?>>2020</option> 12 <option value="2021" <?= $year == '2021' ? 'selected' : "" ?>>2021</option> 13</select>
ちなみに未来投稿の有効化は、functions.phpに下記を記載しています。
※ scheduleというカスタム投稿を作成しています。
php
1function stop_post_status_future_func( $data, $postarr ) { 2 if ( ( $data['post_type'] == 'schedule' && $data['post_status'] == 'future') && $postarr['post_status'] == 'publish' ) { 3 $data['post_status'] = 'publish'; 4 } 5 return $data; 6}; 7add_filter( 'wp_insert_post_data', 'stop_post_status_future_func', 10, 2 );
試したこと
yearが2018の場合は、「option value="2018"」がselectedになりますが、2019や2020、2021の場合は404になり、トップページへリダイレクトしてしまいます。
postをgetにしても、当然改善されず。。
皆さんのお力をお借りできれば幸いです。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/10/17 13:48