Archive For April 30, 2017

Check for missing meta key and fill meta key and value

By |

Check for missing post id’s $qry = “SELECT p.ID FROM nbbuq_posts p WHERE p.post_type = ‘ad’ group by p.ID” ; $psts = $wpdb->get_results( $qry ); Loop through post id foreach($posts as $post){ $id = $post->ID; $qry1 = “SELECT * FROM **_postmeta where post_id=”.$id.” AND meta_key=’ad_featured’”; $psts1 = $wpdb->get_results( $qry1 ); if(isset($posts1[0]->meta_key)) echo $post->ID. ‘ FOUND’;…

Go Top