Sometimes users need conversion any taxonomy terms names into meta data: integer or float values. Reason: desire using range-slider for that values, but trouble in that - range-sliders works only with meta-data. So next algorithm will help you synchronize data:
- Create in meta constructor html-item, type: range-slider for example. Let it be filter of bpm (beats per minute) on your site
- Save it
- Rename meta key of this new range slider, let it be medafi_bpm as example. Of course you can name it as you want with medafi_ prefix only
- Now all your posts have nothing < NULL > in this meta field as its new. But you have terms already with names like: 90,120,150, etc...
- Open your header.php or functions.php and in the same bottom of the file drop next script:1234567891011121314<?phpglobal $wpdb;$pp = $wpdb->get_results("SELECT ID from {$wpdb->posts} WHERE post_type='__POST_TYPE_SLUG_HERE__'");if (!empty($pp)) {foreach ($pp as $p) {$terms = wp_get_post_terms($p->ID, '__TAXONOMY_SLUG_HERE__');if (!empty($terms)) {if (isset($terms[0])) {update_post_meta($p->ID, 'medafi_bpm', $terms[0]->name);}}}}?>
- Replace __POST_TYPE_SLUG_HERE__ to your real post slug where you want set meta data from any taxonomies terms. Replace __TAXONOMY_SLUG_HERE__ to your real taxonomy slug which terms data you are going place to meta fields.
- Refresh any front page of the site if it is opened, or just open any front page
- Remove inserted script from header.php/functions.php and save the file.
- That is all ...