Advertisement
Guest User

Untitled

a guest
Jan 12th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * Delete all the duplicated `_featured` meta data
  5. **/
  6. function clear_listings(){
  7. global $post;
  8.  
  9. $q_args = array(
  10. 'post_type' => 'job_listing',
  11. 'posts_per_page' => '-1',
  12. 'meta_query' => array(
  13. array(
  14. 'key' => '_featured',
  15. 'compare' => 'EXISTS'
  16. )
  17. )
  18. );
  19. $query = new WP_Query($q_args);
  20. while ( $query->have_posts() ) { $query->the_post();
  21. $f_meta = get_post_meta( $post->ID, '_featured', 1 );
  22. delete_post_meta( $post->ID, '_featured' );
  23. update_post_meta( $post->ID, '_featured', $f_meta );
  24. }
  25. }
  26. add_action('init', 'clear_listings');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement