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

Update Custom Post Meta Even if Draft

get_post_meta() without the third parameter will return an empty array if the key isn’t found, so it looks like your check on $remaining_issues will fail every time.

Try

$remaining_issues = get_post_meta($post_id, '_remaining_issues',true);

if ($remaining_issues === false) {  // we only want to update to the default 6 if this has not already been set
              update_post_meta($post_id, '_remaining_issues', '6');
}

Related Posts:

  1. WooCommerce conditional meta query
  2. WooCommerce: Adding Order Item Meta Data That’s Hidden
  3. WP_Query with meta_query for children
  4. How to update custom field in WooCommerce
  5. How to upload multiple image using wp_insert_post
  6. Set default value field meta_Value [closed]
  7. update_post_meta not work [closed]
  8. WooCommerce order refund get qty refunded
  9. WooCommerce Bookings Plugin Not Saving Order ID
  10. Conditionally run function based on custom meta value?
  11. Next/Previous Product with custom order by price & products inside the product category [closed]
  12. How to add custom checkboxes from loop to WooCommerce product variation options?
  13. How to save a Woocomerce metabox input as a metadata field
  14. Can’t update WooCommerce payment method title
  15. How to programatically create a WooCommerce downloadable product?
  16. Updating order meta to have a meta entry from an item in the order
  17. acf_form() – “On Update” action [closed]
  18. Woocommerce – Add a product to cart programmatically via JS or PHP [closed]
  19. ( Woocommerce) How to get the user belonging to an order? [closed]
  20. Get the product list of a given Category ID
  21. List of JS events in the WooCommerce frontend
  22. get woocommerce My account page link
  23. WooCommerce: How to edit the get_price_html
  24. Get woocommerce product price by id [closed]
  25. Product categories don’t appear as option to build menu
  26. WooCommerce Variable Product Price not showing on single product page
  27. How to override WooCommerce template files?
  28. Woocommerce add extra field to variation product
  29. Getting the gallery images from products in woocommerce?
  30. How to get current product category ID in product archive page
  31. Get url of product’s images (woocommerce)
  32. WooCommerce prices location in DB
  33. What is the different between an attachment in wp_posts and an attachment in wp_postmeta?
  34. Order by rating not works in wp_query
  35. Woocommerce: How to remove page-title at the home/shop page but not category pages
  36. Woocommerce show cross sells on singe product page [closed]
  37. How to add a new endpoint in woocommerce
  38. Are there any hook or filter when refund is done through admin -woocommerce
  39. How to check if is in cart page? [closed]
  40. Display single product attribute value on Shop page (Woocommerce)
  41. WP/WooCommerce REST API cart/checkout/order [closed]
  42. how to use wc_create_order with subscription product
  43. WooCommerce: Webhook disabled on its own
  44. What is the code to get the download link for a product in WooCommerce?
  45. Share users and WooCommerce memberships between two installations
  46. Slow Loading Attribute Select – WooCommerce Backend
  47. WooCommerce: Can’t use wc_get_products for custom REST API endpoints
  48. How to change or add Woocommerce thank you page URL key content?
  49. How can I define a custom template for woocommerce [products] shortcode? [closed]
  50. How to remove an action within a class with extends
  51. single-product.php template not working for single products [closed]
  52. Insert variations via woocommerce api [closed]
  53. WooCommerce get physical store address
  54. Is it possible to add custom fields to a WooCommerce attribute term? [closed]
  55. wc_get_template_part( ‘content’, ‘product’ ) | Where is this file located?
  56. how to get woocommerce product attribute slug
  57. Correct function to get the user’s latest Woocommerce Subscription?
  58. Move payment options at checkout in WooCommerce [closed]
  59. add_filter to modify woocommerce_cart_item_name hyperlink
  60. Where do the cart details are stored in database?
  61. How to display product price of the product in loop
  62. How to disable Woocommerce password recovery and use the default WordPress password reset page?
  63. Display order items names in WooCommerce admin orders list [closed]
  64. Is it safe to delete from db orphaned posts i.e. whose post_parent no longer exists?
  65. Add custom variable to cart content [closed]
  66. Get product details by url key in WordPress woocommerce
  67. Get product link
  68. WooCommerce – Hook after Loading Variation in Admin Edit page?
  69. How to delete woo commerce order pragmatically? [closed]
  70. WooCommerce changes lost password reset link
  71. Process checkout using WC REST API
  72. How to get rid of the hover zoom in WooCommerce single products
  73. How do I display certain products via their category on a section of a page using PHP?
  74. How to turn off WooCommerce user registration and manually create accounts?
  75. What’s the difference between WC() and $woocommerce
  76. Display orders instead of woocommerce my account dashboard for logged in users [closed]
  77. Limit users to one active subscription in WooCommerce Subscriptions? [closed]
  78. Detect whether a page is a product subcategory page?
  79. Hidden woocommerce products still showing up in search results [closed]
  80. Menu not show woocommerce product category
  81. Orders being sent to wrong admin email in WooCommerce [closed]
  82. WooCommerce: add different order item meta for each item in order
  83. Remember page before login page, redirect to that page after login
  84. Woocommerce 3.1 Add product image to order confirmation email not working
  85. Where is the “default attribute” values located in the phpMyAdmin in Woocommerce?
  86. Woocommerce My Account Endpoint – how to get ID parameter from URL?
  87. Hook and send Woocommerce data after click Place Order button
  88. Woo-commerce | Disable proceed to checkout button in cart page if total in cart less than 15 [closed]
  89. Fatal Error when installing woocommerce despite upgrading
  90. Adding an action within a function that is being called by add_filter
  91. Default woocommerce placeholder image
  92. How to build a plugin that supports authenticated POST requests to the REST API from external servers?
  93. Hide certain tags on Product Edit tag cloud
  94. WooCommerce: Add New Report Tab
  95. WooCommerce Change Product Global Attribute Value via CRUD for Simple Product [closed]
  96. How to get values from woocommerce admin input fields?
  97. Show only geolocated user country into Woocommerce checkout country fields
  98. Search results don’t show products
  99. Optimizing Woocommerce order items query
  100. What is the right hook to use in WooCommerce for handling the post of the sale price?
Categories woocommerce-offtopic Tags post-meta, woocommerce-offtopic
Creating a search results page from a custom post type in a plugin?
Nested DIV’s across functions in PHP, do not seem to work

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
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 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