It seems you are adding the term ‘selected’ to each option – you only want it added to the currently chosen option.
You can use the WordPress built-in function, selected
, which allows you to compare two values (say the saved term’s ID and the current options term ID) and when they match prints ‘selected’.
For instance:
<?php
$current_term;//Retrieve the current saved term's;
//Get the current term's ID, or 0 if it doesn't exist
$current_term_id = ($current_term ? $current_term->term_id : 0);
?>
<select name="meta-box-events_select" id='meta-box-events_select'>
<option value="" <?php selected(0,$current_term_id)?>>Select Term</option>
<?php
foreach ( $taxterms as $term ) {
echo '<option value="'.$term->slug.'"'. selected($term->term_id,$current_term->term_id).'>'. $term->name . '</option>';
} ?>
</select>
Related Posts:
- Add default WordPress tag meta box to User Profile
- Custom taxonomy hide meta box but show in menu
- How do you remove a Category-style (hierarchical) taxonomy metabox?
- Add description to custom taxonomy admin metabox
- Get the term id belonging to custom taxonomy on a custom single-post-type.php template page
- Automatically assign taxonomy term if custom meta value exists
- How can I conditionally change the title of a taxonomy meta box?
- How to Put Custom Taxanomy Meta Box in Main Column
- Metabox to list/store a certain type of post tag
- Adding content to a taxonomy metabox
- Render P2P metabox per taxonomy term
- Create custom taxonomy and Display in metabox dropdown
- Separate tags with semicolon
- Remove taxonomy widget from “PAGE” post
- unable to save custom taxonomy terms in a custom-built metabox in wp-admin
- Extra Meta Data for WordPress Multisite Taxonomy
- Remove Custom metabox from particular page template is used
- transfer two existing taxonomy terms into one custom metabox
- Looking for suggestions on creating simple database (Help!!)
- How to show/hide a meta box using categories, with a different post type
- Does a codex exist for creating meta boxes in taxonomy
- Attaching meta box to specific category/taxonomy in custom post type
- register_taxonomy – show in admin menu, but not on post type (edit) screen
- Taxonomy Extra Meta [duplicate]
- Modify Term List in Custom Taxonomy Meta Box
- How to prevent new terms being added to a custom taxonomy?
- How to add images to taxonomies?
- Read-only taxonomy (user can assign term but can’t create or edit existing terms)
- Can you add the visual editor to the description field for custom taxonomies?
- Adding Category/Tag/Taxonomy Support to Images/Media
- Taxonomy menu with post count and multiple parents
- Sort Custom Post Type Archive by Taxonomy Term [duplicate]
- Large taxonomy (2000+ terms), causing WordPress to hang
- Is it possible to have a taxonomy archive that lists taxonomy terms?
- Check if current term is a child of another term
- Unable to save custom taxonomy terms in a custom-built metabox
- How to pass posts_per_page and paged params query vars to custom taxonomy archive urls?
- Looping Through Custom Tax Terms and Displaying All Posts For Each
- Exclude Custom Taxonomies
- How to get the top most term (top ancestor) of a custom taxonomy child term?
- Get custom category name from ID
- Set download limit and expiry for WooCommerce downloadable products in specific categories
- Storing data into custom taxonomies VS post custom fields (post meta)
- How can I display my custom metaboxes on a custom post template?
- How to order a list of taxonomy terms alphabetically?
- get_the_terms issue
- ACF vs Taxonomies
- Reverse traversing taxonomy based on term_id
- ‘wp’ action hook not firing in admin and login?
- Display all posts for taxonomy term across multiple custom post types
- Taxonomies on custom taxonomies
- Get list of taxonomies associated with Subscribers
- How to join result of different taxonomies?
- How to add Post Format Taxonomy Archive page in the menu?
- How to add custom label or texts in featured image
- wp_insert_term created and set for first once only
- Show all taxonomy’s terms’ posts having another taxonomy’s term in common
- Adding content to custom taxonomy category pages
- Display formatted list of taxonomy terms with last seperator different
- Trying to add taxonomy to get_categories() but it’s not working. How to fix this?
- Proper WP conditional tag to check for existing taxonomies to list out terms with wp_list_categories?
- Display a colour of custom taxonomy on the page
- Filter through custom taxonomy with an array of taxonomy IDs
- Add attribute taxonomy through code don’t appear in admin product page
- save custom term – hook create_term doesn’t work
- Several taxonomy query (like filter)
- Taxonomy Overview Page?
- How to avoid foreach error WebDevStudio’s WDS_Taxonomy_Radio taxonomy metabox class?
- Can You Build Page Templates Without Extra Files
- How do i make this Taxonomy term code work?
- Unable to get the Parent Custom Taxonomy Terms
- How to list terms by first letter, as in A’s then B’s etc
- Taxonomy hide not working
- Admin only taxonomies?
- Create new Taxonomy, add extra fields, register terms AND extra fields values?
- How to change custom categories term links?
- Body class to each level of a hierarchical custom taxonomy
- Dropdown (with onChange) with custom taxonomies
- set a custom post type to a taxonomy term programmatically in metabox
- How to limit custom post category
- How to get a terms and posts associated with another term?
- How to use two same taxonomy in same post differently?
- Custom taxonomy name not being translated in post manager page
- Automatically Populate Post Taxonomy Data Based on Post Author Meta Data?
- Get Posts by tag from a custom taxonomy
- How to change taxonomy slug?
- Taxonomy to WordPress Permalinks of custom post type
- Avoiding stripping of HTML in Custom Taxonomy Meta Field
- Advanced AND tax_query in sidebar with 2 taxonomies
- Create WordPress taxonomies based on theme settings
- Alternative for is_taxonomy() to workaround theme’s default sidebar
- Can I use get_term_children to show child terms if they exist and show something else if they don’t?
- I’ve got a function that auto creates taxonomy terms – Can it auto delete them as well?
- Get custom taxonomy value of post and output posts in same taxonomy
- Head Code for Custom Taxonomy
- Adding new terms to custom taxonomy
- List posts grouped by children of a custom taxonomy
- Add text in custom taxonomy
- How do I check if a post has a term with a particular ancestor/parent?
- Best approach of implementing multi-select/checkboxes for taxonomies?