$myterms = get_terms($taxonomies, $args);
returns an array of term objects. Use $term->term_id
as option
value …
"<option value="$term->term_id">". esc_html( $term_name ) . "</option>"
… and store that ID, not the name. Names can change, the IDs will stay the same – unless someone deletes a term and creates a new one with the same name.
To select the correct option use selected()
:
"<option value="$term->term_id"" . selected( $term->term_id, $MC_Catalog_course_area, FALSE ) .">"
You can validate the value with absint()
then.
Your save_post
handler needs more checks.
Related Posts:
- Second select list values are not saved after clicking update
- Save data of select list after clicking save
- Why is my custom meta box input not saving
- add_meta_boxes action with refresh on save
- Saving metabox repeatable fields
- How to select the contents in the text view textrea in wp_editor?
- Usage of call back function of add_meta_box()
- Custom meta box values are not getting saved for my custom post type
- How do I make this Metabox show current DB value?
- save_post action inside a custom metabox class not working
- Dropdown category field inside repeatable metabox
- custom field meta-box with dropdown/autocomplete
- Should I use spl_autoload_register() in my plugin?
- How can I save a multiple select array with the settings API for a plug-in options page?
- Using register_activation_hook in classes
- Is there a way for a plugin to add an attribute to the tag of a theme?
- Metabox repeating fields – radio buttons not saving correctly
- Gutenberg Blocks doesn’t render correctly when using do_blocks
- How to store the value of a custom field dropdown select for post referencing?
- simple wordpress ajax plugin not working when not logged in
- How can i create a function to get youtube video time
- Resize Image without cropping
- Custom plugin issue when trying to use the shortcode twice on a page [closed]
- When is is_admin() available?
- How to get all existing post types
- Hiding WordPress Plugin Source Code
- Query String being Removed Creating a Pagination Issue within a Custom Plugin
- wp_loaded hook block script enquequing
- Custom filter in admin edit custom post type responding with invalid post type?
- How to find error in my code when the error message is pointing to WP core file?
- How to access global variable $menu inside a class function
- Filter Select results based on selection
- Custom user login page by creating a plugin
- Singelton class does not work, multiple initialization on page reload
- How to upload a file to a folder named after the user_id via plugin
- developing a wordpress plugin, have a few PHP Woocommerce related coding questions
- How to pick the default selected value in wordpress dropdown?
- Remove metabox from WordPress menu editor page?
- Improve page speed loading using CDN and async or defer attribute
- Whitelisting items from custom options page
- Add_menu_page not displaying the menu in class based plugin
- adjust section according to country?
- What exactly do this function declared into functions.php file of a WP theme?
- How to use html inside a functions.php code?
- Find a way to retrive data updated through metabox plugin to web page
- WordPress Environment: Dynamic Page using shortcode – how to change the page name for sharing
- Extend Woocommerce Widget Class – WC_Widget_Product_Categories
- plugin add action hook is not working :
- zip unzip attachments in wordpress
- wordpress admin plugin menu custom css
- How to Change CSS Colors from Custom Plugin Settings Page
- Passing the name of selected color from the custom component to `render_callback`
- how to Update 15k products on plugin activation with meta_option
- Add editor toolbar to Metabox
- Hooks for post saving make a post-new.php to load latest post’s data
- Adding Additional Variables on Menus Page
- Using flickr api in custom wordpress plugin
- Toolbar Hidden in a Virtual Page
- select a single val though a table in wordpress
- PHP: $_SESSION destroyed after page reload for my custom session
- How to correctly escape an echo
- Payment field disappears on custom Paypal plugin
- Adding image upload in tag section – WordPress plugin development
- How to Remove Theme Style CSS inside Custom Plugin?
- Creating plugin with front-end pages
- How to Send Pingbacks for all Posts in WordPress?
- Reliable way to add nonce to HTTP Header in WordPress?
- I am having errors with checkout on wordpress
- How can I update the price when someone enters postcode or zip code in woocommerce checkout page?
- 400 bad request admin-ajax file upload
- get Woocommerce product format json for WP_Query
- Gutenberg blocks shortcodes compatibility
- Save custom field on WP_List_Table
- Update user meta when an external link in admin notice is clicked
- Is there an option to execute javascript file only on plugin activation
- How do I remove an action hook inside a class that is called by another class?
- The plugin generated 225 characters of unexpected output during activation
- Meta Box clears saved field content
- Ajax in a class instantiated via shortcode
- Parsing webhook from Shopify in WordPress
- Metabox – Displaying the Value of a Metabox
- Shortcode Works for Logged in Users but Not Working for Guest
- Submit to itself don’t work
- WordPress / PhpStorm / XDebug and plugin_dir_path issues
- Send data from plugin to external database
- save_post not called in plugin / custom field still saving overwriting metaboxes
- See output of a sql query while plugin installation in wordpress
- Why this plugin is not working?
- Permission error on plugin save
- How to execute add_action() function from custom plugin to Crontrol plugin or do_action()?
- Display custom meta box in my template file
- base64_encode conflict with convert_smilies in wordpress
- Properly process a custom WP REST API request (Authenticate, Authorize + Validate)?
- Contact form with dynamic dropdown and filter
- Login user into magento using wordpress account
- Redirect users by role to custom pages
- REST API custom endpoints for metaboxes
- getJSON response to PHP
- Custom plugin with shortcode not working
- Customize create table SQL statement in any WordPress plugin