Support

Account

Home Forums General Issues Radio Button isn't showing after saving

Solved

Radio Button isn't showing after saving

  • I created a new field type involved radio button like this:

    <label>
    			<input type="radio" name="<?php echo esc_attr($field['name']); ?>" value="layout-1" />
    			<img src="<?php echo get_template_directory_uri(); ?>/admin/layout-1.png">
    		</label>
    
    		<label>
    			<input type="radio" name="<?php echo esc_attr($field['name']); ?>" value="layout-2" />
    			<img src="<?php echo get_template_directory_uri(); ?>/admin/layout-1.png">
    		</label>
    		
    		<label>
    			<input type="radio" name="<?php echo esc_attr($field['name']); ?>" value="layout-3" />
    			<img src="<?php echo get_template_directory_uri(); ?>/admin/layout-1.png">
    		</label>

    This code is within the ” render_field” function. I can get value. There is nothing to say about that.

    I already put “selected” function in input. But nothing changed.

    My problem is blue circle. When i click the radio button, blue circle show up. But after i publish post, the radio button that i already choose doesn’t have blue circle like this:

    Blue Circle

    So how can i solve this problem ?

  • I solved the issue. It was my mistake. Here is the solution:

    <label>
    			<input type="radio" name="<?php echo esc_attr($field['name']); ?>" value="1" <?php checked( $field['value'], 1 ); ?> />
    			<img src="<?php echo get_template_directory_uri(); ?>/admin/layout-1.png">
    		</label>
    
    		<label>
    			<input type="radio" name="<?php echo esc_attr($field['name']); ?>" value="2" <?php checked( $field['value'], 2 ); ?> />
    			<img src="<?php echo get_template_directory_uri(); ?>/admin/layout-1.png">
    		</label>
    		
    		<label>
    			<input type="radio" name="<?php echo esc_attr($field['name']); ?>" value="3" <?php checked( $field['value'], 3 ); ?> />
    			<img src="<?php echo get_template_directory_uri(); ?>/admin/layout-1.png">
    		</label>
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Radio Button isn't showing after saving’ is closed to new replies.