Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Post meta select input, if statement

I can’t test this but it looks like something like what you have should work:

if ('option1' == get_post_meta($post->ID, 'item_one', true)) { 
  //do something 
} elseif ('option2' == get_post_meta($post->ID, 'item_one', true)) {
  //do something else
} else { 
  //do something else
} 

You didn’t need all those opening and closing tags, and some of them would have caused odd results.

Related Posts:

  1. How to store multiple custom meta box
  2. Unable to Call More than One Meta Box Output
  3. Unable to update the meta boxes with multiple fields
  4. WordPress AJAX load post metadata in modal
  5. If custom field doesn’t exist, or exists and it’s true show title?
  6. How to update custom fields using the wp_insert_post() function?
  7. Get meta_id along with meta_key and meta_value
  8. Metabox repeating fields – radio buttons not saving correctly
  9. How can merge two arrays values in one array and save in database
  10. Check if user already visited this post today
  11. Display all meta for a post?
  12. How to remove a metabox from menu editor page?
  13. Why is my custom meta box input not saving
  14. How to display multiple Post meta_key/meta_values by SQL query
  15. the_post_thumbnail() based on the Post ID
  16. How to use multiple query with same meta key
  17. add_meta_boxes action with refresh on save
  18. How to update single value in multi dimensional Post Meta?
  19. Save selected item from dropdown menu in a meta box as a metadata value for a custom post type
  20. Second select list values are not saved after clicking update
  21. Why is my get_post_meta always empty
  22. Saving metabox repeatable fields
  23. Compare two meta key values against each other inside the get_posts array?
  24. How can update custom meta for all posts
  25. Use ajax to update_post_meta
  26. how to increase custom post value by one most efficiently?
  27. Batch update a post meta field value of each post in Post Type
  28. wp_editor and WPAlchemy messes up tags when updating
  29. How to Display Image Meta underneath EVERY image in EVERY post
  30. Change description on specific WooCommerce product status change
  31. Register non hierarchical taxonomy and the show meta box in the post type
  32. Use WP_Query in shortcode
  33. WordPress update_post_meta updating with empty meta_value field [closed]
  34. Trying to retrieve post meta
  35. can i fetch a custom metabox data in another page or post type?
  36. WordPress from url get external source title
  37. Limit checklist by the current user
  38. How to convert select to HTML with PHP tags inside of it [closed]
  39. Sanitizing text fields in array
  40. Is it possible to retrieve all posts with a certain value for metadata?
  41. Get post id within comments loop
  42. Saving zero in meta box
  43. Non-Closing PHP Query in WordPress Loop
  44. Show meta box only for default page template
  45. Illegal string offset in PHP function
  46. Find a way to retrive data updated through metabox plugin to web page
  47. Why does this update_post_meta function not delete the custom field itself?
  48. Querying Database with wpdb
  49. Metabox Not saving data
  50. meta box not display data input in the textarea
  51. update_post_meta only updating on last loop of foreach
  52. Usage of call back function of add_meta_box()
  53. how to get serialized post meta
  54. How to use two meta_compare in an array?
  55. Remove empty terms from array, sort alphabetically, update back to repeating field
  56. WordPress loop by meta key that is an array? and how loop multiple arrays
  57. WordPress yoast seo plugin – parse snippet var in meta description
  58. Show metabox only for homepage
  59. Add editor toolbar to Metabox
  60. How to add post meta in while loop?
  61. Add category to post meta
  62. Using rules in Posts
  63. Update post meta – Custom field does not match meta-key
  64. Warning: call_user_func() expects parameter 1 to be a valid callback, function
  65. Order a WP_Query by meta value where the value is an array
  66. Save the value of a wp_dropdown_pages
  67. How do I make this Metabox show current DB value?
  68. Add a custom class to the body tag using custom fields
  69. Define category ID using get_post_meta
  70. How to insert data from metabox to custom table
  71. save metabox with new values _wp_page_template
  72. Hide a div when a custom field is empty
  73. Dynamically replicate custom metabox in custom post type
  74. Update value of a associative array with update_post_meta
  75. Front end file upload returning wrong attachment url
  76. Display background color or image with custom meta box?
  77. save_post action inside a custom metabox class not working
  78. Meta boxes only displayed when editing normal (default wp post_type) posts
  79. WordPress stripping out custom field tags
  80. How to check post meta isset or not empty during publish/save post?
  81. get value from get_post_meta then reuse it in another get_post_meta
  82. Add a Metabox checkbox to the Page Edit screen of wp-admin , which only certain roles can see and Makes only certain roles able to Edit said page
  83. Checkbox doesn’t save inside metabox
  84. Order category posts by last word of custom field
  85. Add a “custom field” to a category that can be retrieved when viewing the category page with get_post_meta
  86. Dropdown category field inside repeatable metabox
  87. Create shortcode for metabox gallery
  88. Loop for recently (updated_post_meta) posts?
  89. How to add and subtract user meta values after post meta update
  90. Display metabox galleries on specific page template in admin editor
  91. How to update custom fields when post is published?
  92. Update Images after edit via php
  93. No more get_option(‘date_time’) in WordPress 5.5?
  94. Delete post meta by serialized meta value
  95. Using zip code to display custom data in Admin Order Details
  96. Show a text if the post has written by author user role in WordPress
  97. Hide author from search results meta, still display date and categories
  98. Fix common misspellings/errors based on array of replacements
  99. update_post_meta Not Processing Array Data (Not Sure What I Am Missing)
  100. add ‘publish metabox’ to Gravity forms edit page/form area
Categories PHP Tags metabox, php, post-meta
how to create extra post thumbnail with merge of an icon image?
How To Pass Array To get_the_category_by_ID() and Get An Array Back?

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress