if ( !$value ) evaluates to TRUE when the value is 0.
Alternative:
if ( ! isset ( $_POST['_ordre'] ) )
return delete_post_meta( $post_id, '_ordre' );
update_post_meta( $post_id, '_ordre', $_POST['_ordre'] );
You don’t need add_post_meta(), the call to update_post_meta() will do that automatically.
Related Posts:
- Dealing with Many Meta Values, 30+
- How do i get value from wp_postmeta?
- Why WordPress choose data serialization over json_encode?
- What is the most secure way to store post meta data in WP?
- How to delete outdated, wrongly sized images in _wp_attachment_metadata?
- Meta query interfering with orderby relevance
- Migrating non-WordPress CMS to WordPress, lots of data to move — possible solutions?
- How to solve slow WordPress site caused by attachment_metadata
- Delete all post meta except featured image
- Is it possible to store visitors IPs in wp_postmeta table?
- Multiple postmeta with same name for one post in wp_postmeta table
- Delete all post meta except featured image Using SQL
- One post carries 30 postmeta values, is this too much?
- delete post meta from db, even if does not exist?
- WordPress and MySQL: how to transfer Meta_key and Meta_Value from one post_id to another
- Storing data for a wordpress plugin
- Where does the actual data stored by add_post_meta
- Structure of postmeta meta_value for woocommerce product download
- Routine to convert custom post meta from old to new value
- “The link you followed has expired” & “Error while saving” messages when adding new post
- Uknown meta entries in wp_postmeta
- What’s the proper way to sanitize checkbox value sent to the database
- Does post_meta data need to be unserialzed?
- Link image with data from the wpdb
- Custom Post Type not showing anything added by code anymore?
- Secure way to use name_save_pre?
- Compare User meta_value with Product meta_value
- How to save EXIF metadata in WordPress database?
- _wp_attachment_metadata is not being added to database when PDF files uploaded
- Best Practice? – Saving multiple Values as Serialized Data / Saving each Value per Row / Dedicated Table
- “BS_” rows in postmeta table
- Migrating meta_key and meta_value from old theme to new one
- Database structure for thousands of posts
- How much post meta data is too much?
- Custom metabox does not store data
- Recommended Post Structure for DB Storage
- SQL query : Select a thumbnail for a media
- Query a meta key using an array of values where the database value is a string
- MySQL SELECT increment counter
- Exclude Statement in SQL
- Detecting errors generated by $wpdb->get_results()
- wpdb update add current timestamp not working
- Custom form that store input in database
- update_post_meta and update_field ony working when saving the post
- Displaying content from one WP site on separate WP site
- Lost the `wp_options` table: what’s the best way to restore the site?
- Can a post ID be 0?
- Issue with wp_insert_post and post_content field error Could not update post in the database
- wp_posts – guid update
- Performance Gains of Relational DB Setup
- How to move existing WordPress wp-content folder along with database to new server and new domain name?
- what is the wp_5_posts table in the database?
- Migrating data between local and development server
- WordPress Database Charset/Collate
- store simple data in get_option()
- How might I retrieve a featured post image from an external WP site and display it as a link back?
- What is the database table for pages?
- Using Dynamic Data Pulled from a MySQL Table in a WordPress Page
- What are conventions about the schema of the $table_prefix
- WordPress database becoming huge. How to analyze and optimize it? fear of running out of memory
- BuddyPress: What’s the use of wp_bp_xprofile_data table and how does it get updated? [closed]
- What is an efficient way to query based on post_meta?
- What’s the most efficient database method to add and query usermeta?
- Is database safe after merging a branch of a more recent version over an older one?
- Hook to be used when creating a database table
- Where is custom template file chosen for a post stored in the DB?
- Large database causes slow load
- Safe way to find last inserted id in a table?
- Database slowdown after update to 3.4.1
- WooCommerce sku location in DB
- How to insert data into MySQL database from the form created in WordPress site
- Which is best in the following scenario : post_meta vs custom table vs parent/child posts
- Emoji support and MariaDB 10.0.30-
- WordPress DATABASE Update Manually?
- order by multiple meta_keys?
- I don’t see site_url and home_url fields in wp_options table (phpMyAdmin)?
- Which is more efficient? Using usermeta, or creating a new MySQL table?
- How do I copy a wordpress database?
- Export all content from wordpress
- Import live site to local setup without access to live site
- A field with dashes in the slug [closed]
- Creating a Video Content Page (how to use query strings in wordpress)- Help!
- Modify Database in Multi-Site wp_usermeta table
- Form Data not getting stored in WordPress database
- Hook directly into query execution
- Best way to tell if a user account is active, using the database only
- $wpdb doesn’t like to store arrays
- Connect to a remote database for wordpress in my own hosting server
- Handling large N data in WordPress
- Get Meta Key Value While Saving Post
- How to replicate a user plugin made table value, to this user’s custom meta table value?
- How can I convert postmeta from unserialized to serialized?
- Catalina an MAMP Database Conenction Error
- What Is the Proper Way to Merge Usermeta Table to a an existing WP Database?
- Importing CSV into database table not working?
- A MySQL DB within a MySQL DB
- Is there a way to recover the table wp_term_relationships?
- Trouble Migrating all data blog from WordPress.com to WordPress.org
- “Database Connection Error” upon install in Apache VirtualHost document root.. Why did this happen? [closed]
- How Can I Put Meta_Compare in the Database-Query?