Function Reference/checked displaying checked=’checked’

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:

Read More
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:

enter image description here

Related posts

1 comment

  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 )
    

Comments are closed.