There’s nothing in your code that would allow this to happen. In your HTML you need to add a selected
attribute to the <option>
element representing the current value. WordPress includes a helper function, selected()
which can help with this:
function camere_meta_box_render( $post ){
$number = get_post_meta( $post->ID, "function_camere", true );
echo '<div><select name="function_camere">';
for( $i = 0; $i < 13; $i++ ) {
echo '<option value="'.$i.'" ' . selected( $i, $number, false ) . '>'.$i.'</option>';
}
echo '</select></div>';
}
Related Posts:
- How to add a custom field in the advanced menu properties?
- Sortable Custom Columns in User Panel (users.php)?
- Importing data for advanced custom fields plugin?
- Gutenberg add a custom metabox to default blocks
- How to rename a custom field?
- Filter post listing by meta value which is a date
- Extra profile field as select box?
- Matching Serialized Arrays with meta_query
- Adding Custom Field to Taxonomy Input :Panel
- How to activate “custom fields” section in WP3
- How to filter or search the posts using postmeta tables custom meta fields with wordpress REST API
- Add meta data to the menu
- Copy SEO Meta Desc “Custom Field” to Excerpt field?
- Custom fields won’t display on my blog page
- How to customize default wordpress editor?
- Order Custom post type loop by custom field (datepicker)
- Localized Date Format for Custom Field
- Add an advert every nth Paragraph
- Check if the value of a field has changed on save_post
- How to edit multiple post with Custom fields
- Undefined index error when saving content on metabox
- Saving custom image meta fields
- How to update custom user meta field in wp?
- Query post order by post and desc not working
- If category then echo a custom fields
- How can I show custom fields in the loop only to specific user roles?
- Add conditional custom option to ‘Display name publicly as’ dropdown
- Custom fields not getting saved in the databse when added to the add new user profile page
- I want to send an email when each post is published
- Creating a widget with a number of custom fields
- Show 1 post and after a specific date show the next one
- How to Create Dynamic Fields in a Meta Box?
- Set front page option using custom fields?
- How to order posts by one custom field and filter them by another one?
- Can we create a WordPress read-only virtual field derived from three other fields?
- How to create a gallery custom field for WordPress post?
- Custom Field Values not updating unless I click “Update” twice
- How to display image inside container of custom made widget
- Can I create a template or doctype for my blog site?
- Custom Metabox additional item
- How to combine custom fields to make one order-able value
- Updating Other User’s Metadata
- get_posts in meta box dropdown not showing latest posts
- How to add new field to the account address?
- Split the_title
- Sort WP_Query with numeric custom field
- Display Multiple Values of Same Key
- How to Wrote Simple Calculations by Using Custom Fields in Loop?
- Custom Query based on custom field of a single post
- comment meta_query for keys that aren’t yet set
- How can I use custom properties to set different background on different pages?
- change order of images attached to post
- Loop through incrementing custom fields
- tax query between operator like
- The conditional logic only works to show or hide?
- Single page WordPress website – custom fields or meta boxes or something else?
- Collect Data from NEXT item while in loop
- Order custom fields alphabetically
- How to query for posts with either one or another custom field
- How show post only from after custom date
- How to sort post listing on a page using custom field value?
- Odd functions.php issue in WordPress
- Filter or order based on custom field
- Gutenberg add a custom metabox to default blocks
- How to improve my non-unique metadata MySQL entries?
- How to use ACF with javascript to update custom field values?
- Store comment form custom field in custom database
- Custom Fields Not Showing (ACF not installed)
- Show Custom field value instead of title in WP Menu
- How to add code to custom field to every blog post via php?
- How do I update custom field post meta in frontend post template?
- Sorting post by custom fileds date
- Query multiple meta values at the same time :
- How to Find List of Available Custom Fields for Theme?
- Getting user’s data, by custom field lookup (meta)
- get wordpress post loop by meta box date
- Sort posts by custom fields with empty values
- Sub Field of File Field
- ACF plugin and field update
- Counting number of images from loop
- Automatically set the_post_thumbnail to Custom Field Value
- Redirecting to an external URL
- Adding custom fields to images
- How to save dynamically generated value in post type?
- My meta boxes update wp_postmeta of posts but not of pages. What is wrong with the code?
- how to show this part only in the single post page?
- Import data from arbitrary CSV to WPAlchemy meta fields
- Post thumbnail size for custom field only
- Display meta data from a custom field within plugin Category Grid View Gallery
- Checking if field is set before comparing with meta_query in query_posts?
- Calling a custom profile field only it it exists
- Insert shortcode before and after a list automatically
- Only show content slideshow if “slideshow” custom field exists
- If post custom meta data is not set, show normal state
- Sort posts after filtering them through multiple taxonomies
- update_post_meta based on acf repeater field
- How to include custom field in shortcode (do_shortcode) in theme file
- Query posts by Custom Meta (checkbox) & Genesis Grid Loop
- custom field with links
- WP Query Args – search by meta_key or title