0

Is there a way to count the amount of empty fields of a post (or the fields of a plugin as they relate to the different)?

For example, I have 1,500 posts on my site. Each post has important fields (information) needed for the proper functionality and user accessibility (i.e. city, state, zip code, address, etc), but not every post has all of these fields filled out.

So what I want to do is know how many posts are missing certain fields. For example, how many posts are missing the city field and so forth. Is there a plugin or a function that can count the amount of fields are missing?

I would really appreciate any help or advice with this. This would be very helpful for multiple reasons.

Thanks in advance,

Gary

1

You can do custom query loop for that particular meta box for an empty value. Something along the lines of

$check_city_value = get_post_meta($post->ID, 'city_box'); ?>
if (empty($check_city_value)) {
    echo '$check_city_value is either 0, empty, or not set';
}

You would have to loop through all the posts to do this and for multiple meta box checking it might just be better to use a more direct database query using $wpdb , http://codex.wordpress.org/Function_Reference/wpdb_Class

  • Thanks a lot. I will definitely try this out. It will help me clean up a lot of unnecessary posts and lighten up my database. – user1893 May 27 '11 at 14:28

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.