First of all, save_post
has an argument $post_id
, so there’s no need to global $post
. In some cases, $post
might not actually be set (anymore) when you do this, which is probably why it breaks. Second, you should probably check whether you’re storing a revision or not (see below). So your code should look like this:
function save_details( $post_id ){
if ( wp_is_post_revision( $post_id ) )
$post_id = wp_is_post_revision( $post_id );
update_post_meta( $post_id, "testimonyname", $_POST["testimonyname"] );
}
add_action('save_post', 'save_details', 10, 1);
Related Posts:
- Add a checkbox to post screen that adds a class to the title
- Prevent duplicate posts in wp_insert_post using custom fields
- Add custom fields to post programmatically
- Add a custom meta box in the post options that loads some html code in the header
- Customize rel=canonical tag for single blog post
- Edit multiple custom post types while saving a new or edited post
- if in category but only with post meta
- Adding an option to post editor to show a site disclaimer or message
- How to only allow post to be deleted if custom field doesn’t exist
- How to Do Custom Fields to Output a Definition List
- Where does WordPress store the users customization in the theme
- delete post also attachments
- Attach pdf file to custom post type
- How do I create a featured post within a custom post type?
- I am trying to create a simple frontend form for posting
- HTML code in Custom field
- Static posts page with home.php
- How to show posts rank based on custom field value
- Delete Post Link to delete post, its meta and attachments
- Guest Author – How to modify my custom function code if the guest author URL will follow a particular pattern/format?
- How to edit wordpress RSS feed to show post title only
- Add custom field to category of custom post type
- Change post format using custom field
- How can I make existing custom fields easier to edit/add in my theme?
- What Can I Use To Add A Custom Button Between Publish button and Move To Trash?
- How to get Advanced Custom Field Value According using POST ID? [closed]
- user contributed content as custom post types
- Remove custom posts that match taxonomy value
- Custom Theme Want To Remove One Category From All Displays
- Post Type Label Name
- wp_query ‘s’ parameter does not work with custom post type
- Add custom field automatically (add_post_meta) with value based on number of words of article
- Global $post not working in OOP function WordPress
- Understanding and using metaboxes in posts
- Blog Posts in Custom Menu
- How to display data in archive page?
- I want to display custom text widgets for each post in the sidebar?
- Custom Post Type – Category Rewrite – Remove Rewrite from Sitemap
- CPT archive redirects to single post
- Prevent Delete Attachment by URL or When Submit
- Enable Comments Box On Custom Post Type
- How can i limit the number of posts created per category?
- Turn On Comments On Custom Post Types in Directory Theme
- Duplicate Custom Post Type and Taxonomy Slug
- Calling Different Custom Post Timestamps in a table
- Admin – create custom post status and display above table
- How to allow visitors to filter posts by multiple taxonomies
- How to include my own css in post
- a little direction on custom post type
- Get post ID from a link
- Is codex right on deleting post?
- Create a custom posts page
- Output Post with ACF Fields into other Post
- Deleted a user with administrator rights. Now all the data/content/images are lost. how to recover them back
- register_post_type permalink
- Custom Post Limit for homepage only without plugin?
- l accidentally permanently deleted a Draft. There’s any way I can recover it?
- Static pages not working
- Post titles and thumbnails as links to custom post types?
- Adding a custom post type meta field to rss
- Help with listing current users submitted custom post type in template file
- Getting post and attached image from subdomain
- Deleting old posts
- How To Use Custom Tax of a Post Type
- Help on conditional statement to accompany wp_insert_post function please?
- How to save template data into wp_post table (post_content column)
- Override WordPress core post-template.php block template
- Custom Fields – How to get the list of a specific active widget each time it rendered
- get posts, run a custom query, and join the results
- search form for custom fields
- Saving canvas generated image when saving post causes 404 error
- Some custom post types did not return an object
- Display Post from Custom Post Type with Shortcode
- Modified core/image rendering not showing in posts – only on pages
- Not display an image of category of custom post
- Show post count in custom taxonomy page
- Multiple posts in one page
- Post relationships/nesting
- delete post hook not being fired when deling in wordpress dashboard admin
- Displaying dynamic content (blog posts/portfolio) on a static homepage and keep the blog post styles
- Multiple Custom Post Type loop logic
- WordPress search for specific Post Type
- How can you control what a user is allowed to post in the backend?
- Hook To Get All Posts Deleted
- How to show content of specific item on the same page?
- How to show the posts list into a static page? Problems to use the loop into a static page
- How can I create a menu items from meta box based on users input
- Attaching global meta to custom fields
- WordPress strips some attributes for author posts
- Automatically delete default posts and pages on theme install?
- Display one post randomly from category on home page
- Deleting first four characters from all Post Titles
- Deleling wordpress posts permanently still have IDs
- Post’s arent displaying
- Can I get custom post items in select box (dropdown)
- How to have 2 posting pages on a blog
- Dynamic Menu Item
- Changes done in admin panel are taking time to reflect in the REST api responses
- Read more opens attachment
- I have a website issue I am trying to resolve