Wordpress Functions

Wordpress Functions: checked($checked, $current, $echo )
______________________________________________________________

For use in checkbox and radio button form fields. Compares two given values (for example, a saved option vs. one chosen in a form) and, if the values are the same, adds the checked attribute to the current radio button or checkbox.

Parameters
________________________

$checked
    (mixed) (required) One of the values to compare.
    Default: None

$current
    (mixed) (optional) The other value to compare if not just true.
    Default: true

$echo
    (boolean) (optional) Whether to echo or just return the string.
    Default: true
   
Returns
__________________________

(string)
    HTML attribute (checked='checked') or empty string.
   
Example
__________________________

<input type="checkbox" name="options[postlink]" value="1" <?php checked( $options['postlink'], 1 ); ?> />   

No comments:

Post a Comment