The reason your $item == $option
condition is always failing is because of the way PHP compares floats!
Try the following instead:
echo "<option value="$item"" . selected (abs ($item - $options) <= 0.01, true, false) . ">$item</option>" ;
See Comparing floats for more info.
Related Posts:
- How to make a pagination with dropdown selection?
- How to make drop down post title
- Multiple options not staying selected after saving
- Filter Select results based on selection
- wp_dropdown_pages auto submit
- HTML dropdown setting not showing last saved value in the database
- Sorting dynamic select/dropdown for Contact Form 7 of Modern Tribe Events posts
- Custom Taxonomy Select Menu: Setting default option value?
- How to set value selected using select2 jquery plugin
- Echo Option Value Based On WordPress User Role
- Open WordPress Page from selected option dropdown
- MySQL “Or” Condition
- How to get WordPress Time Zone setting?
- Limit the number of inactive widgets
- How to correctly submit a search form and display the result in an independent page
- Custom plugin: Trying to show saved data on frontend
- Remove/unset options field from backend Settings->General?
- Site Title and Tagline in Theme Options Page
- Editor role cannot save custom theme options
- Drop down+sort blog posts date added/most popular
- Site Title and Tagline in Pagelines DMS Options Panel
- Enqueue Javascript Correctly for 3.5
- Save selected item from dropdown menu in a meta box as a metadata value for a custom post type
- How do I create a drop down menu in a widget?
- Second select list values are not saved after clicking update
- Replacing the NavWalker dropdown element
- Custom widget using get_categories select menu dropdown
- Passing array in add_option()
- Implement a multi-value input field where the number of entries is not limited
- How do I output a database option that is an array into a get_posts array?
- Delete option value from array using update_option()
- Archive dropdown styling not applied
- Getting the dropdown menu to redirect to different pages?
- How to get bool with `get_option()` when already registered setting with type `boolean`
- Settings API – sanitize_callback is not called and it leads to an incorrect behavior
- Store and Work with huge array in WP [closed]
- how to save selection meta data in user profile on frontend
- Adding Default Settings to Theme My Login plugin
- How to add values to media “whitelist_options” in wp-admin/options.php template?
- Ajax – Call to undefined function get_option()
- Custom profile field with birthday. Troubles with
- How to pick the default selected value in wordpress dropdown?
- Whitelisting items from custom options page
- Options API get_option() and update_option() Not Correctly Updating or Returning
- how to save selected option in variable for rest api category filter
- Setting default category base on theme activation
- Display parent and child taxonomies in separate drop down select fields
- Error: options page not found
- How to store options in an array
- how to update and display an option without reloading the page
- Security for data obtained from the database
- How to convert select to HTML with PHP tags inside of it [closed]
- Pull GetOption() variable into jQuery dynamically created html
- Filtering a Database Query
- add onchange to select in a wp form
- Is a series of update_option calls safe, performance wise?
- wp-options keep crashing please help
- WP_OPTIONS table, active_plugins entry [closed]
- Warning: Illegal string offset on theme options page [closed]
- Link blogname and blogdescription to the Options Framework
- Isotope Drop Down Categories Filter Function
- retain querystring values when savincustom options in admin
- Why can’t I return a value from $wpdb->get var?
- How to Change CSS Colors from Custom Plugin Settings Page
- Decimal values via get_option() with custom local (decimal point = comma)
- How to show every second user different types of banners?
- How to use wp_nav_menu to create custom dropdown menu?
- WordPress language switcher doesn’t work
- Save the value of a wp_dropdown_pages
- Get value from db for custom contact form
- Add a select-option to the default widgets
- go to home page when i select default in select-box
- Page Options Saving But Not Updating In Backend
- Compare current post Category in select menu
- Add a custom WooCommerce settings tab with sections
- Database SQL query error
- Set all WooCommerce Products to Simple, Virtual & Downloadable
- No more get_option(‘date_time’) in WordPress 5.5?
- Load google font script based on optgroup label selected
- Reload page with a different shortcode when a user selects from a dropdown
- How to update option field in database on clicking the publish button in customizer
- add image in dropdown select
- Get Link of Page Selected through a Select Field in Custom Admin Page
- PHP drop down menu for my get_category child of
- dropdown with no submit
- Use get_option with $emailTo on contact page
- custom field meta-box with dropdown/autocomplete
- Page 2+ of taxonomy archives does not recognise sort-order from dropdown
- Save data of select list after clicking save
- WordPress Setting page can not be saved by html radio
- AJAX with Selectbox Plugins (Select2, Chosen, Selectize)
- Dropdown Menu for Query_Posts
- Save Option on Database
- Integrating CSS Into a WP Function Call [closed]
- Options.php loop won’t show!
- Echo get_option displays as text
- Contact form with dynamic dropdown and filter
- WordPress shortcode select option not working [closed]
- Dynamic Email Handler with ‘header (“Location: …’
- save array of objects with update_option