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
- Automatically add date to the auto generation of post slug
- Permission issue with custom post type – not added to menu – by plugin
- Duplicate Custom Post Type and Taxonomy Slug
- How could I change my Permalink from blog to custom structure? [closed]
- Categories list into registration form
- Remove Custom Post Type Slug and add Custom Taxonomy to Permalink Structure?
- Take a received feedback item, turn it into a post
- Getting value from get_post_custom
- WP Admin register taxonomy and post type performance
- Static posts page with home.php
- Calling Different Custom Post Timestamps in a table
- WordPress Multisite – Create Default Post and New Category On New Site Install
- Admin – create custom post status and display above table
- custom post template file not shown, instead all the time 404.php
- Set Default Category to Username
- Query Posts With Over 1000 Views
- How to allow visitors to filter posts by multiple taxonomies
- Cannot retrieve a custom RSS field from posts
- show custom post type category dropdown sorting result on same page
- Custom Post Type Rewrite To Include Parent Page(s)
- Thumbnail & Category link aside post
- Hooking into the post editing screen for an existing page only
- Query Posts by Custom Field
- Redirect to another page using contact form 7? [closed]
- How to include my own css in post
- Custom post types related to same custom post type?
- How do I insert a post with custom post type and relate it to a custom taxonomy?
- Dynamically switch template on click
- How to rate a post from Admin Side / Manually?
- “about us”, ” contact” sections should be article(post) or page in the simple small Business website?
- Is it possible to customize the post according to post format in single.php?
- How to I retrieve the ID from the Posts page?
- a little direction on custom post type
- disable Tab post on nav-menus page (Admin)
- Format latest/newest post differently
- Get post ID from a link
- Custom taxonomy archive page problem
- Tell WP to use a specific template file in posts
- Create a list of posts with topic headdings
- Add field to user meta table in database when link is clicked
- Hide custom metabox value from custom fields
- Is there a way to create a meta box that can be added multiple times to a post dynamically?
- relating business and products with custom taxonomy?
- Best Way to Add UnEditable HTML to Posts
- Get post meta retrieving wrong value
- How safe is it to delete old posts edits to save database space?
- Two Custom Post Types with Identical Articles Competing for the same Slug
- Custom Post Type archive
- WordPress custom post type with folder structure in slug
- Using setup_postdata() with multi-dimensional array
- Is codex right on deleting post?
- Check if a custom post type has already been created
- WordPress Query Posts From Category Post on Static Page
- Create a custom posts page
- How to add automatically bootstrap 4 order-lg-1 and order-lg-2 classes for columns in foreach loop based on the count?
- How to get different Related Posts
- How to add convenient buttons for new custom post statuses
- How to allow multiple thumbnail upload for Posts?
- add external project to web site wordpress on production
- 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
- Saving Post Data in Another Database
- Show custom post with custom categories with specific slug
- register_post_type permalink
- Display the 2nd category name of a custom post type without error if its null?
- Auto delete posts based on content text
- How to call posts under a specific category on static front page?
- Querying another post category to match current post and display in loop
- Custom home page with full post for first one only
- Custom Post Limit for homepage only without plugin?
- Add two custom fields as a default to the “new post” page.
- After ajax image is outside the “ tag
- Display value of custom field at the beginning of a post
- Edit custom fields in posts list
- Add multiple meta keys to a post at once
- l accidentally permanently deleted a Draft. There’s any way I can recover it?
- datepicker value in mysql
- WP_Query custom field pass the post id
- Inserting an example of the last 3 post on to the homepage
- Static pages not working
- Optimize CPT-function with a loop
- Add post tags to previously created custom post type
- If custom field is empty, use one from a previous post
- Can WordPress handle following functionalities?
- saving/reading custom field value does not work – no value gets POSTed
- Simple Custom Metabox Not Saving
- Get a term each custom post type
- Change default post style to columns
- Post titles and thumbnails as links to custom post types?
- Custom Post Type, post-formats associated to custom post type > 404 archives