I use this code to list unique values of custom field name "authors" from all posts. It works just fine, but I would like to limit results, to get values which appear in at least for example 20 posts? How to drop out custom field values which are in use in less than 20 posts?
<ul> <? global $wpdb; $query = "SELECT DISTINCT meta_value FROM $wpdb->postmeta WHERE meta_key = 'authors' ORDER BY meta_value;"; $authors = $wpdb->get_results( $query ); foreach( $authors as $author ) : echo'<li>'; echo $author->meta_value; echo '</li>'; endforeach; ?> </ul>