Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Delete all the duplicated `_featured` meta data
- **/
- function clear_listings(){
- global $post;
- $q_args = array(
- 'post_type' => 'job_listing',
- 'posts_per_page' => '-1',
- 'meta_query' => array(
- array(
- 'key' => '_featured',
- 'compare' => 'EXISTS'
- )
- )
- );
- $query = new WP_Query($q_args);
- while ( $query->have_posts() ) { $query->the_post();
- $f_meta = get_post_meta( $post->ID, '_featured', 1 );
- delete_post_meta( $post->ID, '_featured' );
- update_post_meta( $post->ID, '_featured', $f_meta );
- }
- }
- add_action('init', 'clear_listings');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement