问题
I am currently working on a wordpress options page, checking if options are checked.
When i check with the following code the correct check boxes are selected, but next to the checkbox i get the following:
checked='checked'
Here is my code:
echo '<input name="wwo_enable_'.$lrole.'" type="checkbox" value="1" '.checked( '1', get_option( 'wwo_enable_'.$lrole ) ).' />';
And a screen shot to show what i mean:
回答1:
The last parameter of the checked() function is whether it's echo'd or not. Since it's true by default you need to add the third parameter as false.
Should be able to switch this:
checked( '1', get_option( 'wwo_enable_'.$lrole ) )
To this:
checked( '1', get_option( 'wwo_enable_'.$lrole ), false )
来源:https://stackoverflow.com/questions/31843872/function-reference-checked-displaying-checked-checked