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:
- How to store multiple custom meta box
- Unable to Call More than One Meta Box Output
- Unable to update the meta boxes with multiple fields
- WordPress AJAX load post metadata in modal
- If custom field doesn’t exist, or exists and it’s true show title?
- How to update custom fields using the wp_insert_post() function?
- Get meta_id along with meta_key and meta_value
- Metabox repeating fields – radio buttons not saving correctly
- How can merge two arrays values in one array and save in database
- Display all meta for a post?
- How to remove a metabox from menu editor page?
- the_post_thumbnail() based on the Post ID
- How to use multiple query with same meta key
- add_meta_boxes action with refresh on save
- Why is my get_post_meta always empty
- Saving metabox repeatable fields
- Compare two meta key values against each other inside the get_posts array?
- Use ajax to update_post_meta
- How to Display Image Meta underneath EVERY image in EVERY post
- Change description on specific WooCommerce product status change
- Register non hierarchical taxonomy and the show meta box in the post type
- Use WP_Query in shortcode
- Customize Plugin
- Random order of WP_Query results with highest meta value
- Trying to remove post thumbnail with plugin
- Randomly Assign an Image’s Alt Text Based on Data From Post
- Can I prevent the user from adding more than two levels deep of terms inside of a taxonomy metabox?
- Loop with slider (slider not loading)
- Creating user status mode in WordPress
- Need Help Fixing My Iframes [closed]
- Remove metabox from WordPress menu editor page?
- WordPress update_post_meta updating with empty meta_value field [closed]
- can i fetch a custom metabox data in another page or post type?
- WordPress from url get external source title
- How to convert select to HTML with PHP tags inside of it [closed]
- Get post id within comments loop
- Non-Closing PHP Query in WordPress Loop
- Show meta box only for default page template
- Find a way to retrive data updated through metabox plugin to web page
- Querying Database with wpdb
- Metabox Not saving data
- meta box not display data input in the textarea
- update_post_meta only updating on last loop of foreach
- how to get serialized post meta
- How to use two meta_compare in an array?
- Remove empty terms from array, sort alphabetically, update back to repeating field
- WordPress yoast seo plugin – parse snippet var in meta description
- Add editor toolbar to Metabox
- How to add post meta in while loop?
- Add category to post meta
- Using rules in Posts
- Order a WP_Query by meta value where the value is an array
- Save the value of a wp_dropdown_pages
- How do I make this Metabox show current DB value?
- Add a custom class to the body tag using custom fields
- How to insert data from metabox to custom table
- save metabox with new values _wp_page_template
- Dynamically replicate custom metabox in custom post type
- save_post action inside a custom metabox class not working
- Meta boxes only displayed when editing normal (default wp post_type) posts
- WordPress stripping out custom field tags
- How to check post meta isset or not empty during publish/save post?
- get value from get_post_meta then reuse it in another get_post_meta
- Add a “custom field” to a category that can be retrieved when viewing the category page with get_post_meta
- Dropdown category field inside repeatable metabox
- Create shortcode for metabox gallery
- Loop for recently (updated_post_meta) posts?
- How to add and subtract user meta values after post meta update
- How to update custom fields when post is published?
- Update Images after edit via php
- No more get_option(‘date_time’) in WordPress 5.5?
- Delete post meta by serialized meta value
- Using zip code to display custom data in Admin Order Details
- Show a text if the post has written by author user role in WordPress
- update_post_meta Not Processing Array Data (Not Sure What I Am Missing)
- WP post meta – for loop inside for loop
- Get meta values from parent post and save in child post
- Reverse Cross-Sells (WooCommerce)
- Meta Box clears saved field content
- When working with a post, almost all wp_postmeta are deleted
- Post Meta statement?
- Get value of submit button in custom post type
- Updating Lat and Lng of posts automatically gives sporadic results
- Metabox – Displaying the Value of a Metabox
- meta field for numerous links
- Inline Styling a div from a Custom Metabox
- get_post_meta with variable
- custom field meta-box with dropdown/autocomplete
- Display a post based on its metabox selection
- get_post_meta is always empty when I use wp_mail
- Metabox Input Not saving
- Creating a function that sanitizes the custom metabox excerpt
- How to Publish WP original Source metabox value on front-end webpage
- How to add together (get the sum) a field from all author’s posts
- Display custom meta box in my template file
- How to display the date under the post title?
- send meta box input data without publish button
- metabox displaying on incorrect page
- Warning: Illegal string offset ‘post’ and ‘page’
- How to get meta box labels?