Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

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

share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.