MENU

WPFormsの必須項目に表示される*(アスタリスク)を「※必須」に変更するfunction.phpのコード

WPFormsの必須項目には*(アスタリスク)が表示されますが、ひと目で必須であることが分かるように「※必須」に変更するfunction.phpのコードです

公式WPForms Developer Documentationより

WPForms
Using the wpforms_get_field_required_label filer with WPForms The WPForms wpforms_get_field_required_label filter is used to change the required field indicator for any required form fields.
WPForms
How to Change the Required Field Indicator for required fields in WPForms Do you want to change the required field indicator for fields that are marked required? We can show you how to achieve this using PHP.

function.phpへの追記内容

// WPFormsの必須項目に表示される*を※必須に変更
function wpf_dev_required_indicator( $text ) {  
    return ' <span class="wpforms-required-label">' . __( '※必須', 'wpforms' ) . '</span>';
}
add_filter( 'wpforms_get_field_required_label', 'wpf_dev_required_indicator', 10, 1 );

// [公式] https://wpforms.com/developers/wpforms_get_field_required_label/
// [公式] https://wpforms.com/developers/how-to-change-the-required-field-indicator/

[※必須] の箇所は必要に応じて書き換える

よかったらシェアしてね!
  • URLをコピーしました!
  • URLをコピーしました!

この記事を書いた人

作業ログです
WPFormsの紹介がひととおり終わったら、360度撮影やワードプレステーマ(Snow Monkey やSWELL)とかWoocommerceのことも残していく予定

目次