getting a posts ID for save_post action
-
Hi everyone.
I’d like to add a custom field (meta info) to a post when it gets saved.
Let’s say, the actual plugin functionality is in function do_something(). So now I added the action for ‘save_post’:add_action('edit_form_advanced', 'do_something'); add_action('save_post', 'mark_post_edited');
and created a corresponding function:
function mark_post_edited() { global $post; add_post_meta($post->ID, 'valid_markup', '1', true); }
This way the function doesn’t really know which post is edited. It does alter the field post_id with a value of ‘0’.
As this isn’t the actual posts’ ID, here’s my question:
How do I make the actual ID available across both functions?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘getting a posts ID for save_post action’ is closed to new replies.