• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WP Discuss

Wordpress Research & Analytic

  • Submit
  • Disclaimers
  • About
  • DMCA
  • Privacy Policy
  • Contact

September 27, 2019 by [post_author_posts_link_outside_loop] Leave a Comment

Get_term_meta() always returns false

I added an extra field (dropdown list with select options), when the user creates or edits a category from the WordPress dashboard. I am also able to store the selected value in the wp_termmeta table. However, I need to display the selected value from the dropdown list after page refresh. I am using the functions get_term_meta() and update_post_meta(), however get_term_meta() always returns false and I cannot assign a selected value for any of the options:

function changePostOrder(){ $post_order = get_term_meta($_POST['tag_ID'], 'post-order', true); var_dump($post_order); // $post_order returns false, while it should return oldest or newest ?> <tr class="form-field"> <th scope="row" valign="top"><label for="post-order"><?php _e('Post Order'); ?></label></th> <td> <select name="post-order" id="post-order"> <option <?php if ($post_order == 'oldest') { ?>selected="true" <?php }; ?>value="oldest">oldest</option> <option <?php if ($post_order == 'newest') { ?>selected="true" <?php }; ?>value="newest">newest</option> </select> </td> </tr> <?php } add_action ( 'edit_category_form_fields', 'changePostOrder'); 

As a result, after page refresh the dropdown list is again the same (oldest is selected), even though in the database the meta_value column is “newest”. Am i doing something wrong? I am using the same approach as suggested in the second answer here.

  • Daniil Kvyat gets Formula 1 return for 2019 with Toro Rosso
  • Raiders finalize terms for return to Oakland in 2019
  • 2015 Nissan Versa Note SR Long-Term Update 1
  • 2014 Subaru Forester 2.0XT Long-Term Verdict
  • Maryland comptroller suspends returns from four more tax preparers
  • 2015 Kia K900 V-8 Long-Term Update 9
  • 2015 Nissan Versa Note SR Long-Term Update 5
  • 2012 Volkswagen Passat SE TDI Long-Term Arrival
  • 2016 Chevrolet Camaro SS Long-Term Verdict
  • Vauxhall Insignia Sports Tourer on long-term test: the sleek family estate with loads of promise
Get_term_meta() always returns false have 325 words, post on wordpress.stackexchange.com at September 27, 2019. This is cached page on WP Discuss. If you want remove this page, please contact us.

short term investments with high returns, registering for self assessment and getting a tax return, term return of premium insurance, term return of premium life insurance, high investment returns short term, should i get term life insurance, can i get false teeth on the nhs, where to get the best returns for your money, where to get false eyelashes applied, stock market long term returns

Primary Sidebar

RSS Recent Stories

  • How to Choose an SEO Friendly WordPress Theme?
  • 10+ Best WordPress Directory Plugins
  • 25 Best Elementor Addons for WordPress 2021
  • 8+ Best WordPress Popup Plugins
  • How To Streamline WordPress for User Experience

Sponsored Links

  • Phú Quốc authority wants to bring ’troublesome’ Russian girl to mainland
Copyright © 2021 WP Discuss. Power by Wordpress.