0

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 ) {
    YOUR_FUNCTION_HERE( $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,

1

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.

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.