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

Simple Custom Metabox Not Saving

This is because save_post hook function accepts post id as parameter and not post object so the save_custom_meta function should be as following.

/** Save the Data **/
function save_custom_meta($post_id) {
    // verify nonce
    if (!wp_verify_nonce($_POST['shortdesc_meta_box_nonce'], basename(__FILE__))) 
    return $post_id;
    // check autosave
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
    return $post_id;
    // check permissions
    if (!current_user_can('edit_post', $post_id))
    return $post_id;

    //echo $_POST['_desc'];
    //die();

    if(isset($_POST['_desc']))
        update_post_meta($post_id, '_desc', strip_tags($_POST['_desc']));
}
add_action('save_post', 'save_custom_meta', 1, 2);

Related Posts:

  1. How can I retrieve multiple get_post_meta values efficiently?
  2. How to batch update post content with custom post meta value
  3. What Can I Use To Add A Custom Button Between Publish button and Move To Trash?
  4. Using radio button meta data from a custom meta box
  5. Using Custom Posts with Metaboxes and Drop-downs
  6. Adding custom fields to bbpress reply form
  7. Meta value does not save for scheduled posts
  8. Getting value from get_post_custom
  9. Calling Different Custom Post Timestamps in a table
  10. Customize rel=canonical tag for single blog post
  11. How to I retrieve the ID from the Posts page?
  12. How to save meta checkbox WordPress
  13. Is there a way to create a meta box that can be added multiple times to a post dynamically?
  14. if in category but only with post meta
  15. Updating post meta for checkbox
  16. How can I tell if a post has been published at least once?
  17. Adding a meta box to determine the sidebar [closed]
  18. How to bulk Update URLs to new values?
  19. Adding an option to post editor to show a site disclaimer or message
  20. Meta boxes not saving
  21. Display metabox with date
  22. How to compare two posts including their meta fields on a scalable base?
  23. Permission issue with custom post type – not added to menu – by plugin
  24. Duplicate Custom Post Type and Taxonomy Slug
  25. How could I change my Permalink from blog to custom structure? [closed]
  26. Remove Custom Post Type Slug and add Custom Taxonomy to Permalink Structure?
  27. Take a received feedback item, turn it into a post
  28. WP Admin register taxonomy and post type performance
  29. Add a custom meta box in the post options that loads some html code in the header
  30. Static posts page with home.php
  31. WordPress Multisite – Create Default Post and New Category On New Site Install
  32. Admin – create custom post status and display above table
  33. Simultaneous admin updates causes custom fields to not update
  34. Is it possible to paste a link without tags and make it directly a link in a post?
  35. custom post template file not shown, instead all the time 404.php
  36. Set Default Category to Username
  37. How to allow visitors to filter posts by multiple taxonomies
  38. Cannot retrieve a custom RSS field from posts
  39. show custom post type category dropdown sorting result on same page
  40. Custom Post Type Rewrite To Include Parent Page(s)
  41. Thumbnail & Category link aside post
  42. Saving custom fields to a custom taxonomy
  43. How to automate featured posts number? [duplicate]
  44. How to include my own css in post
  45. Custom post types related to same custom post type?
  46. How do I insert a post with custom post type and relate it to a custom taxonomy?
  47. Dynamically switch template on click
  48. “about us”, ” contact” sections should be article(post) or page in the simple small Business website?
  49. Is it possible to customize the post according to post format in single.php?
  50. Change all author links in Blog roll
  51. a little direction on custom post type
  52. disable Tab post on nav-menus page (Admin)
  53. How to calculate the average of a post meta value(Numeric) of a specific author
  54. Format latest/newest post differently
  55. Custom taxonomy archive page problem
  56. Is there any way to tell when wp_postmeta has been updated?
  57. Tell WP to use a specific template file in posts
  58. Hide custom metabox value from custom fields
  59. relating business and products with custom taxonomy?
  60. Best Way to Add UnEditable HTML to Posts
  61. Get post meta retrieving wrong value
  62. How safe is it to delete old posts edits to save database space?
  63. Two Custom Post Types with Identical Articles Competing for the same Slug
  64. Custom Post Type archive
  65. WordPress custom post type with folder structure in slug
  66. wpColorPicker – problem with implementation to post meta
  67. Using setup_postdata() with multi-dimensional array
  68. Is codex right on deleting post?
  69. Check if a custom post type has already been created
  70. WordPress Query Posts From Category Post on Static Page
  71. Edit multiple custom post types while saving a new or edited post
  72. Let’s Create Custom Field Template Documentation
  73. Upload attachment from external site
  74. Create a custom posts page
  75. Change post author without using wp_update_post()
  76. Show metabox value last post excerpt, title and link
  77. How to add automatically bootstrap 4 order-lg-1 and order-lg-2 classes for columns in foreach loop based on the count?
  78. How to get different Related Posts
  79. How to add convenient buttons for new custom post statuses
  80. wp_query with ajax
  81. Update post meta within save_post action
  82. How to allow multiple thumbnail upload for Posts?
  83. Display post number by category
  84. add external project to web site wordpress on production
  85. Deleted a user with administrator rights. Now all the data/content/images are lost. how to recover them back
  86. Saving Post Data in Another Database
  87. Show custom post with custom categories with specific slug
  88. register_post_type permalink
  89. Display the 2nd category name of a custom post type without error if its null?
  90. Auto delete posts based on content text
  91. How to call posts under a specific category on static front page?
  92. Querying another post category to match current post and display in loop
  93. Custom home page with full post for first one only
  94. Custom Post Limit for homepage only without plugin?
  95. Custom permalink for each post
  96. Is there a way getting post fields using `transition_post_status`
  97. Automatic blog page with custom design [closed]
  98. Display value of custom field at the beginning of a post
  99. Add multiple meta keys to a post at once
  100. Show number of posts by logged in user
Categories posts Tags customization, metabox, post-meta, posts
custom post types missing ADD NEW
how wordpress smtp works? my emailing is not working

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