WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

As per this thread I'm scheduling a wp_cron every hour which runs a function. The function I'm running is reasonably lengthy and I didn't want authors to have to deal with the waiting times.

My question is this - when creating a function which runs from the following code ($ids is a list of post IDs):

$ids = unserialize( get_option( 'my_updated_posts' ) );
foreach( $ids as $v ) {

How do I a) retrieve content if the id relates to a Post type and then update it, or b) update meta fields if said id is actually a species Custom Post Type?

For b), will I have to update each meta field individually or is there a filter I can apply?

Thanks in advance,

share|improve this question
up vote 1 down vote accepted

I would filter which posts go into the option, that's light enough processing that it can be done on that end.

To get the content of the post you can use get_post( $v );.

To get the metavalues for the post you can use get_post_custom( $v );.

To update the meta values you will use update_post_meta(). You will have to do these individually.

share|improve this answer

Your Answer


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.