下記の過去のQ&Aを参考に、エラー文言の位置を変更しようとしていますが、まったく変わらないので困っています。。
https://teratail.com/questions/103474
該当のソースコード
まずfunctions.phpに下記を追記しました。
php
1function wpcf7_custom_item_error_position( $items, $result ) { 2 $class = 'wpcf7-custom-item-error'; 3 $names = array( 'month1','day1'); 4 5 if ( isset( $items['invalidFields'] ) ) { 6 foreach ( $items['invalidFields'] as $k => $v ) { 7 $orig = $v['into']; 8 $name = substr( $orig, strrpos($orig, ".") + 1 ); 9 if ( in_array( $name, $names ) ) { 10 $items['invalidFields'][$k]['into'] = ".{$class}.{$name}"; 11 } 12 } 13 } 14 return $items; 15} 16add_filter( 'wpcf7_ajax_json_echo', 'wpcf7_custom_item_error_position', 10, 2 );
日付の選択で「月」「日」の前にエラーメッセージが出てしまうので、後ろに移動したいです。
html
1[select* month1 class:form-control include_blank "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12"]月 2<span class="wpcf7-custom-item-error month1"></span> 3[select* day1 class:form-control include_blank "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "20" "21" "22" "23" "24" "25" "26" "27" "28" "29" "30" "31"]日 4<span class="wpcf7-custom-item-error day1"></span> 5
参考Q&Aに「バージョンによって、$itemsの値が変わっている」とありますが、もしこれが関係している場合、変わっているかどうかはどのように調べればよいでしょうか?
下記のような情報が取得できれば解決に近づきそうですが。。(Filter?)
Array ( [into] => #wpcf7-f5-p24-o1 [status] => validation_failed [message] => 入力内容に問題があります。確認して再度お試しください。 [invalidFields] => Array ( [0] => Array ( [into] => span.wpcf7-form-control-wrap.fav [message] => 必須項目に入力してください。 [idref] => ) ) )
詳しい方教えていただけると嬉しいです。よろしくお願いいたします。m(_ _)m
補足情報(FW/ツールのバージョンなど)
WordPress 4.9.8
Contact Form 7 5.0.4
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。