WordPress 小部件单选按钮不保存 → 仅 PHP 没有 Js/JQuery
WordPress Widget Radio Buttons not saving → Only with PHP no Js/JQuery
这是小部件的完整代码 →
<p> <input type="radio" <?php checked( $instance[ 'what_to_check_for' ], 'check_for_counter' ); ?> id="<?php echo $this->get_field_id( 'check_for_counter' ); ?>" value="check_for_counter" name="what_to_check_for" />
<label for="<?php echo $this->get_field_id( 'check_for_counter' ); ?>">Check whether to display description or not</label> </p>
<p> <input type="radio" <?php checked( $instance[ 'what_to_check_for' ], 'check_for_image' ); ?> id="<?php echo $this->get_field_id( 'check_for_image' ); ?>" value="check_for_image" name="what_to_check_for" />
<label for="<?php echo $this->get_field_id( 'check_for_image' ); ?>">Select to Post with Thumbnails</label> </p>
问题 →
问题是单选按钮没有保存。为此,我在下面附上了一段视频。
单选按钮未保存 → https://www.screencast.com/t/pLad8AwrOXiS
Please guide me where I am going wrong. Is isset
missing for this
radio button? If yes, then help me finish that.
试试这个代码。它的工作。
<p> <input type="radio" class="what_to_check_for" <?php checked($what_to_check_for ,'check_for_counter'); ?> id="<?php echo $this->get_field_id( 'check_for_counter' ); ?>" value="check_for_counter" name="<?php echo $this->get_field_name( 'what_to_check_for' ); ?>" >
<label for="<?php echo $this->get_field_id( 'check_for_counter' ); ?>">Check whether to display description or not</label> </p>
<p> <input type="radio" class="what_to_check_for" <?php checked($what_to_check_for ,'check_for_image'); ?> id="<?php echo $this->get_field_id( 'check_for_image' ); ?>" value="check_for_image" name="<?php echo $this->get_field_name( 'what_to_check_for' ); ?>" >
<label for="<?php echo $this->get_field_id( 'check_for_image' ); ?>">Select to Post with Thumbnails</label> </p>
这是小部件的完整代码 →
<p> <input type="radio" <?php checked( $instance[ 'what_to_check_for' ], 'check_for_counter' ); ?> id="<?php echo $this->get_field_id( 'check_for_counter' ); ?>" value="check_for_counter" name="what_to_check_for" />
<label for="<?php echo $this->get_field_id( 'check_for_counter' ); ?>">Check whether to display description or not</label> </p>
<p> <input type="radio" <?php checked( $instance[ 'what_to_check_for' ], 'check_for_image' ); ?> id="<?php echo $this->get_field_id( 'check_for_image' ); ?>" value="check_for_image" name="what_to_check_for" />
<label for="<?php echo $this->get_field_id( 'check_for_image' ); ?>">Select to Post with Thumbnails</label> </p>
问题 →
问题是单选按钮没有保存。为此,我在下面附上了一段视频。 单选按钮未保存 → https://www.screencast.com/t/pLad8AwrOXiS
Please guide me where I am going wrong. Is
isset
missing for this radio button? If yes, then help me finish that.
试试这个代码。它的工作。
<p> <input type="radio" class="what_to_check_for" <?php checked($what_to_check_for ,'check_for_counter'); ?> id="<?php echo $this->get_field_id( 'check_for_counter' ); ?>" value="check_for_counter" name="<?php echo $this->get_field_name( 'what_to_check_for' ); ?>" >
<label for="<?php echo $this->get_field_id( 'check_for_counter' ); ?>">Check whether to display description or not</label> </p>
<p> <input type="radio" class="what_to_check_for" <?php checked($what_to_check_for ,'check_for_image'); ?> id="<?php echo $this->get_field_id( 'check_for_image' ); ?>" value="check_for_image" name="<?php echo $this->get_field_name( 'what_to_check_for' ); ?>" >
<label for="<?php echo $this->get_field_id( 'check_for_image' ); ?>">Select to Post with Thumbnails</label> </p>