Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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,...)

share|improve this answer
    
amazing - thank you so much! –  Matt Apr 4 '12 at 10:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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