Question : checked function in wordpress
Answered by : energetic-emu-5snqv9jpdaca
<!-- Testing the values with if() -->
<input type='checkbox' name='options[postlink]' value='1' <?php if ( 1 == $options['postlink'] ) echo 'checked="checked"'; ?> />
<!-- Using checked() instead -->
<input type="checkbox" name="options[postlink]" value="1" <?php checked( $options['postlink'], 1 ); ?> />
Source : https://developer.wordpress.org/reference/functions/checked/ | Last Update : Tue, 20 Sep 22