Without knowing the surrounding code, it is hard to tell what the problem might be,
but you said you checked the $post
variable. Maybe the $post
variable is not set properly, the save_post
action only gives you the post id:
function get_post_title($post_id) {
$post = get_post($post_id);
if (empty($post->post_title)) {
// No title set, put in your code
}
}
add_action('save_post', 'get_post_title');
Related Posts:
- Auto save title as custom meta field value
- Execute action after post is saved with all related post_meta records (data)
- Add post meta based on another post meta value before publish post
- Get updated post meta on save_post action?
- Correct processing of `$_POST`, following WordPress Coding Standards
- Delete post meta conditionally after save post
- Set default Custom Post Meta Value
- Editing does not change post_name
- Save post meta foreach loop
- troubles with get_post_meta (and saving it)
- wp_insert_post inside save_post adds wrong metadata to inserted post
- Save frontend submission form field as custom field
- get_post_meta() returns nothing in save_post, publish_post, wp_after_insert_post
- if condition from post_meta not working in save_post
- Get posts by meta value
- Force post slug to be auto generated from title on save
- How get post id from meta value
- Safe to delete blank postmeta?
- advanced custom fields update_field for field type: Taxonomy
- update_post_meta not saving when value is zero
- Restrict post edit/delete based on user ID and custom field
- Remove post meta keys
- How to access the post meta of a post that has just been published?
- delete unused postmeta
- List posts under meta_value heading
- Using Advanced Custom Field (ACF) to insert meta description on each page
- How to add meta tag to wordpress posts filter?
- update_post_meta() whenever custom post type is updated
- Metabox Data not being saved [closed]
- Options to get my custom post type metadata via the WordPress API
- Generate an Email address from that of the Post Author
- How to get the total number of meta_values based on a custom post type?
- Saving html into postmeta without stripping tags – safe?
- Does “update_post_meta” check if value is the same before updating?
- Add a meta value if admin , editor or any other user have open a post in edit mode
- Finding the page id
- WP_POSTMETA – What do these values mean inside the data structure?
- Update Line Item Meta Data – WooCommerce API
- “update_post_meta” not working in “wp_insert_post_data” hook
- Unset field from an array not working as expected
- Update post_meta with WooCommere variation data
- What type of index should I use for postmeta?
- How to create a meta_query to get all posts with a specific meta data?
- Meta function issue
- Saving zero as meta value
- Get a row from a separate table by matching a posts meta_key to a tables ID column
- get_post_meta is showing file url in url bar
- get_post_meta not extracting title,permalink and posttype
- How to check if a post meta key/value pair already exists for a specific post
- Reset/delete post views meta/custom field after X hours or minutes or seconds
- Difficultly changing date format in post meta value
- Remove last character in get_post_meta
- Have lots of meta for posts, is it better to get at all at once or each individually
- Query posts WITHOUT a custom meta field
- How to obtain a group of post meta and assign each meta to other variables?
- Add box with custom per-page properties
- get_post_meta not working when variable used for post ID
- Update post meta dynamically
- Run a function on all posts
- update_post_meta in loop changing ALL values
- Is it safe to add a new field to meta_value field?
- Need a SQL query to update meta_key=’_price’ with value in meta_key=’_regular_price’
- Display current user’s custom post meta in sidebar
- add_post_meta doesn’t work
- Change auto post title generation according to different post properties
- How to get single value from get_post_meta() array of values?
- Editor meta box Showing but not saving
- How can I use ‘orderby’ => ‘meta_value_num’ to order by the numerical value even if the value starts with a word?
- wordpress update multiple posts post meta
- get_template_part() isn’t loading author information
- New Table vs Post / Comment Meta
- get Insert id for meta field
- Is there a way combine posts meta_name?
- Format meta_value [closed]
- How to check post meta isset or not empty during publish/save post?
- get specific values from WordPress meta_value
- Is duplicate `_wp_attachment_image_alt` meta key allowed?
- Count Post and Page Views based on meta_value Using Shortcode in Dashboard Widget
- Removing Malware
- After updating the custom post type, metafields disappear from the post.php edit menu, how do I fix it?
- URL from get_post_meta() is broken my URL
- get_post_meta and add_post_meta not working
- Export media library with metadata and import into new blog
- Multiple meta key and value search in the query
- Why doesn’t wp_oembed_get() for the video post format not work?
- Re-pointing images to cloud storage
- How to get a post meta value and pass that to update_option when a post is created or updated?
- undesrtanding get_post_meta function
- Retrieve posts from meta key
- Assign postmeta in bulk
- Problem with ‘save_post’ hook not running
- Posts with no meta field do not appear when sorting by meta field
- How do I delete element from a serialized array upon deletion of a post?
- How to create a link for wordpress meta datas?
- Get meta information from post parent
- Counting number of identical meta keys
- wp_postmeta store multiple values in one key [closed]
- query with custom field
- Using Form to alter PHP variable [closed]
- Chance post id into post name