0

I have the following action callback set up:

function abc_save_post($post_id, $post)
{
    // do stuff

    echo '<pre>'.print_r($post,true).'</pre>';
}
add_action('save_post', 'abc_save_post', 10, 2);

The thing is that $post is a very trimmed down version of $_POST and is missing lots of data that I want to get at. How can I get more data into $post?

1

Simply use the post ID, provided by $post_id (and stored at $post->ID) to use the various functions WordPress provides to get any extra data related to that post (get_the_terms,get_post_meta etc).

Performance wise you suffer no loss by using these functions as opposed to trying to force more data into the $post object (probably the reverse in fact), since WordPress caches data related to posts (such as taxonomy terms, post meta,...)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.