0

I have 200 blog articles linked to different users. Now I moved them to new Pods custom field "author" because I don't want different user that could access to my blog.

The problem is that I have to link every post to different "author" custom field. Is it possible doing this operation in bulk mode or i have to edit every single article?

0

Solved! I've created this script:

<?php
  global $wpdb;
  $postwp = $wpdb->get_results ( "SELECT ID,post_author,post_title FROM wp_posts WHERE post_status = 'publish' and post_type = 'post'" );
  $users = $wpdb->get_results ( "SELECT post_id,meta_value FROM wp_postmeta where meta_key = 'id_utente_user'" );

  foreach($postwp as $key1=>$value1)
  {
    foreach($users as $key2=>$value2)
    {
       if($value1->post_author==$value2->meta_value)
       {
           add_post_meta( $value1->ID, 'autore', $value2->post_id );
       }
   }
  }
  ?>

I hope It could be useful.

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.