Get meta data from wp_options table
Posted by navaneeth on Sep 25, 2012 in Php, Wordpress | 1 Comment
In wordpress wp_options table, option_values are(some values) saved as serialized.So directly we can’t get those values.
Now i’ll tell you easy method to get meta data from wp_options table.
I want to get option name – ” tax_meta_25 “, values.
Values like this.(i want to get values corresponding to ba_pm3 )
a:13:{s:16:"ba_text_field_id";s:4:"0.75";s:6:"ba_fc1";s:4:"1.95";s:6:"ba_fc2";s:4:"1.75";s:6:"ba_fc3";s:4:"1.00";s:6:"ba_pm1";s:4:"2.50";s:6:"ba_pm2";s:4:"2.25";s:6:"ba_pm3";s:4:"2.00";s:6:"ba_se1";s:4:"1.50";s:6:"ba_se2";s:4:"1.00";s:6:"ba_se3";s:4:"0.50";s:5:"ba_i1";s:4:"3.00";s:5:"ba_i2";s:4:"2.50";s:5:"ba_i3";s:4:"2.00";}
First get data like this .
<?php $val=tax_meta_25; //desired values to be fetched $opt = $wpdb->get_row("SELECT * FROM $wpdb->options WHERE option_name = '$val'"); $opts=$opt->option_value; ?> Now unserialize those data like this. <?php $array = unserialize($opts); echo $array["ba_pm3 "]; ?>
And you have the values
Hope this will help you to get meta data from wp_options table.
One Comment on “Get meta data from wp_options table”
Heena
December 7, 2017Thank you so much. Its really help me a lot.