You need to check to see whether the $_POST
data contains your custom field information before saving it:
if (!empty($_POST["intro"])) {
update_post_meta($post->ID, "intro", $_POST["intro"]);
}
Also, WordPress will pass the post ID and post object into your callback if you ask it too.
function save_intro($ID, $post){ //preserve the data in the admin section
// ...
}
add_action('save_post', 'save_intro',10,2);
You don’t need that global $post
at all.
Related Posts:
- Custom Field data only shows after manual post update
- Exclude URL’s from sanitize_html_classes
- adding autosave feature to custom fields
- WP_Query – Order results by meta value
- Custom query with orderby meta_value of custom field
- Difference between meta keys with _ and without _ [duplicate]
- Orderby meta_value only returns posts that have existing meta_key
- How to enable revisions for post meta data?
- Any way to add custom options to Gallery Settings?
- Can I query custom meta data through WP_Query
- Including custom fields in search?
- How to display all custom fields associated with a post?
- Change behavior of “Insert into Post” based on attachment metadata
- Sort posts by custom field numeric value using dropdown
- How to position a custom field before the editor
- How can I display all values of a custom field from posts with a certain value of another custom field or from certain post types?
- passing argument to get_template_part() or a better way to code
- Is there a way to do multiple ordering on a multiple meta_query?
- searching in custom meta field
- How to add upload field in a custom taxonomy?
- Display thumbnail from custom field
- Bulk move (or copy) from a custom field to the post content?
- Getting Custom Field data from a page hierarchy
- Custom contact form 7 select with custom values [closed]
- limit amount of photos uploaded per cpt post
- Problem with adding exta field in metabox in custom post type
- Move value of one custom field to another
- Setting orderby to a custom field using pre_get_posts
- little help with a mySQL query to wp database
- Add WYSIWYG to Image Description field
- How do I query for a post by custom field?
- Calling custom profile fields?
- How to Display Custom Meta Box only on Specific Page IDs
- Get custom field label
- Show ACF fields only on certain page in the backend
- Performance of storing multiple meta fields vs one JSON encoded field [duplicate]
- Create Multiple File Upload Metabox in WordPress
- WP_User_Query pulling ACF to loop
- how to put a custom field value in variable
- Custom Metabox Not Saving
- How to add image attachment to post from a single meta key (Woocommerce)
- How to add the image URL from an external RSS feed and insert into a custom field?
- My custom backend codes shows up when i try to view my website
- Advanced Custom Fields dynamic update_field
- Custom Profile Fields move from BBpress to BuddyPress
- How can I output a list of values for a custom field, and posts with those values?
- Manipulate javascript code from custom made admin page menu
- Add additional ‘description’ field for defined roles / role metadata?
- Change the main loop WordPress impact on the server?
- How to get categories with posts by custom field value?
- Meta Query returns wrong number of posts
- How to hide a custom field if there is not a value
- Display Custom Field for a Specific Role, but not for Admin
- Avoiding ACF get_field and returning to core WordPress function
- Walker class for sub-menu with ACF fields
- Display custom field value part by part?
- Add custom fields to existing posts (admin pages)
- Multiple instances of TinyMCE are removing tag
- How do i get the attached images with custom value checked?
- How to disable Edit Post and Allow only Custom Field?
- Convert attachment ID into url?
- How to query an out put value?
- Cannot save underscore custom fields in one wordpress installation using xmlrpc and underscores
- Diamond question mark in text after migrating content
- Retrive Image URL of Custom Fields in Theme
- Display posts with empty custom field
- Custom Fields Question
- do_shortcode close
- Add custom data (field) to sidebar widgets for later display
- How do I convert all custom_field php timestamps in the database to js timestamps?
- Display custom field value as a mailto: link
- wordpress get_post_meta / the_meta to output custom field value
- Display custom field only if it has a value
- Make separate text boxes for separate WordPress Custom Fields
- Sort by an ACF field in a tax_query
- Allow HTML in Custom Metabox area
- Custom field metabox not showing in back-end
- Load one page with parent and child pages
- Why can’t I get the correct post permalink
- Use a different catalog image than the featured image
- Login Api with Meta_key and Meta_value
- Query Multiple meta
- Extra text’n’image field in a page
- Get first URL from custom field, download and set as featured image on post publish
- Media Attachment Custom Meta Fields not saving in Media Uploader when using jQuery UI Autocomplete
- How to add an option to admin to add image that could be used as header?
- Custom Field add markup to line breaks
- Use Metabox to enter Post Title
- Include custom fields into the content of a regular page
- Bypassing a Form Options
- How to query posts that have certain post meta keys, and sort by meta key and/or value
- sort a custom field base on the date or anything
- How to implement jquery-ui autocomplete into custom fields?
- Add image custom attribute [closed]
- i want to send email on custom post field (job_status == 2) but it is not working
- Foreach giving one too many list items, how can I remove the last empty line?
- I used a custom field for header image and can’t get it to show up on posts
- Add custom fields to specific menus
- Truncating characters in Advanced Custom Fields works some places but not others?
- How to add an ACF only for parent term?