The second parameter of selected()
has to agree with the value
attribute of the current <option>
. So assuming you have stuffed $selected
with the value given by the relevant get_post_meta()
, the following should work for you:
<label for="myplugin_meta_box_select">Status:</label>
<select name="myplugin_meta_box_select" id="myplugin_meta_box_select">
<option value="Approved" <?php selected( $selected, 'Approved' ); ?>>Approved</option>
<option value="In Progress" <?php selected( $selected, 'In Progress' ); ?>>In Progress</option>
</select>
Side note: I’d personally prefer to use the “sluggish” version (i.e. inprogress
instead of In Progress
) for the value
attribute (and thus for the post meta value), but you’d have to make changes to your front-end as well.
Related Posts:
- Prevent sorting and dragging of specific postbox metabox
- How to access global $wp_meta_boxes variable on front-end?
- remove_meta_box for all post types doesn’t seem to work
- Custom Meta Box (SELECT) Not Saving
- How to add select list to meta box field?
- Resetting admin post form on JS validation fail
- Why do Metabox use Nonces?
- WP admin display custom field if another field value is “Female”
- Error showing in current page id in wordpress admin
- Can’t save drop down select date in meta boxes
- Hooking into the Meta Boxes (Name/Web Address/Description) on the ‘Add New Link’ Page
- Create more Meta Boxes as needed
- Set Default Admin Screen options & Metabox Order
- How to set default screen options?
- Passing error/warning messages from a meta box to “admin_notices”
- Disable dragging of meta boxes?
- Add “upload media” button in meta box field
- Add a Meta Box for uploading a SECOND Featured Image?
- Does WordPress have a “Form API”?
- Metabox with checkbox is not updating
- How to HIDE everything in PUBLISH metabox except Move to Trash & PUBLISH button
- What is the “Advanced” $context in add_meta_box?
- Removing panels (meta boxes) in the Block Editor
- Change The Title Of a Meta Box
- WordPress SEO by Yoast: Hide Meta Boxes in Posts for Non-admins
- How to make open/closed and hidden/shown metaboxes status saved on a per-post basis?
- How To Remove The “+ Add New Category” Link From A Category Metabox
- Taxonomy dropdown metabox in the back-end
- How can I create a taxonomy meta-box with search suggestions but no new terms input?
- Remove the Featured Image Meta Box
- Remove the Yoast SEO Post Metabox [closed]
- Best practices for meta box placement?
- Creating a metabox to upload multiple images
- How Does WordPress Remember Metabox Positions?
- Sample code for validating custom metabox?
- Using TinyMce with textareas in meta boxes on custom post types
- Post custom metabox textarea using wp_editor
- How to Add Reminders/Notes to New Post Meta Boxes
- How do I get attachment_id?
- Removing Metabox for “Slug” without removing functionality
- How to reorder meta box position?
- One metabox for multiple post types
- How do I position meta_box on post edit screen after the title?
- How to add a class to meta box
- Remove unusable metaboxes in nav menu management screen
- Has anyone successfully integrated qtranslate with custom metaboxes?
- Put the media uploader in a metabox
- Custom Meta Boxes: multiple fields within a repeatable field
- Removing meta boxes: remove-meta_box() or unset()?
- Save checkbox value in metabox
- How to group meta boxes on the post edit page
- Use meta box drag and drop to order items independently
- inside a metabox
- Add Meta box Befoure Post Title
- Hiding a theme’s meta box
- Metabox date month number to word
- get registered metaboxes by post type or post ID
- Remove metabox from specific page template in admin
- Is there a filter/action to add content to WP admin metaboxes?
- Attach Files Metabox
- CMB2 metabox conditional logic
- Tinymce/WordPress is removing all line-breaks?
- How do I create a meta box for dates?
- Adding submit or update button to custom metabox?
- Editing the Default Links like “Site Admin” in the Sidebar Meta Section?
- How to pass variable via $callback_args for add_meta_box
- Undefined function error when creating Custom Meta Box
- How to get meta box data to display on a page
- esc before saving or before displaying does it matter?
- Block metabox – No expanding, no moving around
- Move excerpt to always be directly below post content in admin
- Access the environment of an admin page from another admin page
- Add a meta description to home page?
- Editing Screen: Make Update or Publish Button Follow The Page
- Removing custom meta box added in parent theme
- Add filter ‘wpautop’ to meta box textarea
- How to limit the pages displayed for choosing parent page on page attribute’s menu?
- Get all posts from custom post type and insert in select input as metabox
- Use meta box value in CPT as post title
- Custom “Publish” / “Update” button &
- Why can’t I hook into save_posts after admin_init?
- Meta Boxes in Front End Post Submission Form
- Getting the ID of a meta box
- how to sanitize checkbox input?
- add_meta_box does not go ‘side’
- Custom filter for the_content doesn’t work correctly
- Replacing select2 in admin backend for all selects
- Remove a plugin meta box from the dashboard
- How to insert Gallery shortcode to a meta box
- Getting jQuery sortable items in custom metabox
- Custom meta box shown when template is chosen [duplicate]
- Modifying the main editor priority
- How to make a meta box field a requirement
- Check if meta key value already exists
- How to make multicheck for post/page meta box
- Display list of tags as drop down menu or radio buttons in a meta box?
- How to select one major category (or custom taxonomy) for a custom post type?
- Populating meta box with select-list of existing posts, and assigning it to custom post types
- Adding uploaded images to editor from metabox instead of default popup uploader
- How do I stop HTML entities in a custom meta box from being un-htmlentitied?