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

I have a lot of posts under category 'tution', which has custom field called 'video'. i need to update the 'video' value with same youtubeurl i.e all post would have the same value in the custom field 'video'. how should i proceed. Is their a query?

share|improve this question

Use get_posts to get all the posts in this category, then loop over it and update the post meta for every post.

//get_posts uses same parameters as WP_Query hence using 'category_name'
$tut_posts = get_posts(array('category_name'=>'tution', 'post_status'=>'publish'));
$url = //some youtube video url here
    foreach($tut_posts as $tut_post){
        update_post_meta($tut_post->ID, 'video', $url);

Please check if this works for you.

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.