I know this is maybe a dumb question. I am trying to retrieve data from the wordpress table wp_postmeta, specifically the meta_value column. Is there a function in php to get every field from that kind of data?
For example how can I get the "Gabriela Castro en Costa Rica" value from this
a:1:{s:14:"billing-seller";a:3:{s:4:"name";s:14:"billing-seller";s:5:"value";s:29:"Gabriela Castro en Costa Rica";s:5:"label";s:26:"Select one option, please.";}}
Thanks.
This seems like a serialized array, im not familiar with Wordpress but maybe try something like this:
get_user_meta( '99999', 'your-key', true );
You can find more information to get_user_meta here:
get_post_meta()
is the function you need to use.
$value = get_post_meta( $post_id, 'key', true );
Where $value
will be your string.
https://codex.wordpress.org/Function_Reference/get_post_meta
First of all, the serialized string I posted came from doing this:
get_post_meta($order->orders, '_custom_billing_fields', true);
That was giving me this(the original question):
a:1:{s:14:"billing-seller";a:3:{s:4:"name";s:14:"billing-seller";s:5:"value";s:29:"Gabriela Castro en Costa Rica";s:5:"label";s:26:"Select one option, please.";}}
Now this is what I did to get the value I was trying to substract:
$sellerBigArray = (array)maybe_unserialize(get_post_meta($order->orders, '_custom_billing_fields', true));
$sellerArray=$sellerBigArray['billing-seller'];
$seller=$sellerArray['value'];
I hope it helps.
Bye