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
- Is it fine to have foreign key as primary key?
- Detecting errors generated by $wpdb->get_results()
- wpdb update add current timestamp not working
- Restoring WordPress posts from database only
- update_post_meta and update_field ony working when saving the post
- Displaying content from one WP site on separate WP site
- So much data in postmeta
- Performance Gains of Relational DB Setup
- store simple data in get_option()
- What are conventions about the schema of the $table_prefix
- 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?
- storing database in version control
- Is deleting orphaned wp_options entries safe?
- How to build a movie database with wordpress?
- Sub-domain or 2nd, temporary different domain?
- How do i get user data from a custom table in the wordpress database by user ID?
- Converting WordPress into Android or iPhone app
- Delete duplicate rows from wordpress database where a column is duplicate in phpmyadmin
- 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-
- Can I have multiple database users within WordPress?
- Modify Database in Multi-Site wp_usermeta table
- Form Data not getting stored in WordPress database
- $wpdb doesn’t like to store arrays
- Connect to a remote database for wordpress in my own hosting server
- WordPress ‘repairing database’ in a constant error loop?
- What Is the Proper Way to Merge Usermeta Table to a an existing WP Database?
- Importing CSV into database table not working?
- Use same database on main domain & sub domain
- Best practice to limit results in get_row()?
- displaying an error before update_post_meta
- Serialize data before inserting into the DB
- Reinstalling wordpress from database breaks the site
- Pages from custom table
- Trouble running $wpdb->query() with last_insert_id
- Save meta data with post, Without using any plugin [closed]
- Can I customised default WP table
- Woocommerce – Check product stock availability from external database
- Get results from wordpress data custom table
- How to display data from db in select list [closed]
- Will adding & modifying default WordPress table index break future WordPress update
- Database migration issues – Error #1046 No database selected
- echo site_url() returns a different value than what is in the database siteurl field
- Native timestamp on wp_options option
- SELECT rows between two datetimes when the range is dynamic [closed]
- How to get the full stack trace for WordPress “table doesn’t exist” error in debug.log?
- How to access a table in a wordpress database using REST API?
- error establishing a database connection 3
- Correct and secure way to access a custom SQL database in a custom PHP template file
- save_post doesn’t correctly process function call with php class
- Missing latest posts and options after DB migration via phpMyAdmin
- Local host to server import problem
- Restoring .sql backup results in “Error establishing a database connection”
- “MySQL server has gone away” since update to 3.8
- Getting deleted users in database
- Options of accessing wordpress data from mobile app
- Getting data from a table using a query
- Database interaction (private-public) [closed]