Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Saving zero as meta value

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:

  1. Dealing with Many Meta Values, 30+
  2. How do i get value from wp_postmeta?
  3. Why WordPress choose data serialization over json_encode?
  4. What is the most secure way to store post meta data in WP?
  5. How to delete outdated, wrongly sized images in _wp_attachment_metadata?
  6. Meta query interfering with orderby relevance
  7. Migrating non-WordPress CMS to WordPress, lots of data to move — possible solutions?
  8. How to solve slow WordPress site caused by attachment_metadata
  9. Delete all post meta except featured image
  10. Is it possible to store visitors IPs in wp_postmeta table?
  11. Multiple postmeta with same name for one post in wp_postmeta table
  12. Delete all post meta except featured image Using SQL
  13. One post carries 30 postmeta values, is this too much?
  14. delete post meta from db, even if does not exist?
  15. WordPress and MySQL: how to transfer Meta_key and Meta_Value from one post_id to another
  16. Storing data for a wordpress plugin
  17. Where does the actual data stored by add_post_meta
  18. Structure of postmeta meta_value for woocommerce product download
  19. Routine to convert custom post meta from old to new value
  20. “The link you followed has expired” & “Error while saving” messages when adding new post
  21. Uknown meta entries in wp_postmeta
  22. What’s the proper way to sanitize checkbox value sent to the database
  23. Does post_meta data need to be unserialzed?
  24. Link image with data from the wpdb
  25. Custom Post Type not showing anything added by code anymore?
  26. Secure way to use name_save_pre?
  27. Compare User meta_value with Product meta_value
  28. How to save EXIF metadata in WordPress database?
  29. _wp_attachment_metadata is not being added to database when PDF files uploaded
  30. Best Practice? – Saving multiple Values as Serialized Data / Saving each Value per Row / Dedicated Table
  31. “BS_” rows in postmeta table
  32. Migrating meta_key and meta_value from old theme to new one
  33. Database structure for thousands of posts
  34. How much post meta data is too much?
  35. Custom metabox does not store data
  36. Recommended Post Structure for DB Storage
  37. SQL query : Select a thumbnail for a media
  38. Query a meta key using an array of values where the database value is a string
  39. wp_update_post function exclude specific field
  40. What is an ORM, how does it work, and how should I use one? [closed]
  41. What is the difference between an ORM and an ODM?
  42. What is this JavaScript “require”?
  43. Rename a table in MySQL
  44. How should I tackle –secure-file-priv in MySQL?
  45. What is this JavaScript “require”?
  46. What is “Advanced” SQL?
  47. What’s the difference between identifying and non-identifying relationships?
  48. Can’t connect to MySQL server on ‘127.0.0.1’ (10061) (2003)
  49. Can’t connect to MySQL server on ‘127.0.0.1’ (10061) (2003)
  50. Can’t connect to MySQL server on ‘127.0.0.1’ (10061) (2003)
  51. What are the differences between B trees and B+ trees?
  52. MySQL SELECT increment counter
  53. How to resolve ORA-011033: ORACLE initialization or shutdown in progress
  54. Example of a strong and weak entity types
  55. Oracle SQL query for Date format
  56. phpMyAdmin – Error > Incorrect format parameter?
  57. Strange Characters in database text: Ã, Ã, ¢, â‚ €,
  58. Difference between partition key, composite key and clustering key in Cassandra?
  59. How SID is different from Service name in Oracle tnsnames.ora
  60. What is a relation in database terminology?
  61. Failed to connect to mysql at 127.0.0.1:3306 with user root access denied for user ‘root’@’localhost'(using password:YES)
  62. Database vs File system storage
  63. Can I have multiple primary keys in a single table?
  64. Exclude Statement in SQL
  65. How do you query for “is not null” in Mongo?
  66. What is a file based database?
  67. Is it fine to have foreign key as primary key?
  68. Storing Images in DB – Yea or Nay?
  69. Using wpdb to connect to a separate database
  70. how to Optimize WordPress database for 10 million post? [duplicate]
  71. MySQL Database User: Which Privileges are needed?
  72. Why is my database import losing text widget data?
  73. How to only display posts whose meta_value field is not empty?
  74. Database synchronization between dev/staging and production
  75. Keeping WP database synced across multiple developers using git
  76. Post meta vs separate database tables
  77. WPDB Insert or if exists Update
  78. Multiple developers / editors working on a site in progress
  79. Passing error/warning messages from a meta box to “admin_notices”
  80. How can I make updates to a site, on a development copy, but then move updates back without overriding live site’s evolving database?
  81. get_results using wpdb
  82. Will it break my site if I delete all transient records in wp_options table?
  83. Checking if Database Table exists
  84. What’s the simplest way to backup my WordPress database?
  85. WordPress (MyISAM) database is slow, should I switch to InnoDB?
  86. $wpdb won’t insert NULL into table column
  87. Relaunch 4.2 utf8mb4 database upgrade
  88. Fastest way (least amount of steps) to locally import a remote database using WP-CLI
  89. Safest way to bulk delete post revisions
  90. Please explain how WordPress works with MySQL character set and collation at a low level
  91. Solution for database version control and deployment?
  92. The MySQL alternatives: Do Percona Server and MariaDB work well with WordPress, and do they make WordPress go better?
  93. How many users can WordPress handle?
  94. Get error messages when $wpdb->insert() returns false?
  95. Detecting errors generated by $wpdb->get_results()
  96. Staging sites, how do you manage synchronising updates in the DB?
  97. Does dbDelta delete columns as well?
  98. How to get the post publish date outside the loop?
  99. MariaDB as a backend database
  100. wpdb update add current timestamp not working
Categories Database Tags database, meta-value, post-meta, save-post
Query Posts With Over 1000 Views
How do I display a custom field from a custom taxonomy in single.php?

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Post Navigation Elementor
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • WPFacet multiple loop displaying duplicate content
  • Get the name of the template/*html file used
  • Fix: WordPress.DB.PreparedSQL.NotPrepared Plugin Check (PCP)
  • Removing unnecessary CSS and JS code from wp_head()
  • hexagonal image gallery. Am I on the right track? [closed]
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress