Custom Field – Select option – show text not value
-
Hi,
When adding a multi select custom field it is displaying the value on the advert page rather than the text selected. In wordpress and on the edit page it shows the text. How can I display the text on the single details page not the value?
Code for adding as per the custom field docs:
add_filter( "adverts_form_load", "my_adverts_form_load" ); function my_adverts_form_load( $form ) { if( $form["name"] != "advert" ) { return $form; } $form["field"][] = array( "name" => "item_condition", "type" => "adverts_field_select", "order" => 30, "label" => __("Condition", "adverts"), "max_choices" => 1, "options" => array( array( "value" => 1, "text" => "Good", "depth" => 1 ), array( "value" => 2, "text" => "Fair", "depth" => 1 ), ) ); return $form; } add_action( "adverts_tpl_single_details", "my_adverts_tpl_single_details" ); function my_adverts_tpl_single_details( $post_id ) { $co = get_post_meta( $post_id, "item_condition", true); <?php if(! empty($co) ): ?> <div class="adverts-grid-row"> <div class="adverts-grid-col adverts-col-30"> <span class="adverts-round-icon adverts-icon-wordpress"></span> <span class="adverts-row-title">Condition</span> </div> <div class="adverts-grid-col adverts-col-65"> <?php esc_html_e( $co ) ?> </div> </div> <?php endif; ?>
Thanks
Greg
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Custom Field – Select option – show text not value’ is closed to new replies.