Custom field (get_post_meta) issue
-
Hi,
I’m having trouble to display the value of a custom select field in frontend of my website.
1) I have added this custom select field in backend:
woocommerce_wp_select( array( 'id' => 'myfieldname', 'label' => __( 'My Select Field', 'woocommerce' ), 'options' => array( 'one' => __( 'Option 1', 'woocommerce' ), 'two' => __( 'Option 2', 'woocommerce' ), 'three' => __( 'Option 3', 'woocommerce' ) ) ) );
2) I save value like this:
update_post_meta( $post_id, 'myfieldname', esc_attr( $_POST['myfieldname'] ) );
3) Display it on frontend:
echo get_post_meta(get_the_ID(), 'myfieldname', true );
BUT, after I select for example ‘option 2’ in backend, this is displayed in frontend like this: ‘two’
So part ‘Option 2’ is not displayed. Guess something’s wrong with code of step 3?
Guido
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Custom field (get_post_meta) issue’ is closed to new replies.