Software Developer

Conditional Output Based On Radio Button or Select Meta Input

This is useful if you have a custom meta field that uses radio button or ‘select’ input, and you want to display something in a template file depending on the meta value. This can also be used for regular text input meta fields, as well. In the example below, my custom meta field is a radio button named ‘_isa_edp_radio’. If ‘EDP’ is selected, it prints one thing. If ‘EDT’ is selected, it prints another thing. If nothing is selected, it doesn’t print anything.

IF CUSTOM META VALUE IS THIS OR THAT, DO THIS OR THAT:

$key = '_isa_edp_radio';
$edpedt = get_post_meta( $post->ID, $key, true );
if ( $edpedt == 'EDP' ) {
	echo 'Eau de Parfum';
} elseif ( $edpedt == 'EDT' ) {
	echo 'Eau de Toilette';
}

See more:

By

Questions and Comments are Welcome

Your email address will not be published. All comments will be moderated.

Please wrap code in "code" bracket tags like this:

[code]

YOUR CODE HERE 

[/code]