[wp-hackers] Meta boxes and post metadata

Neil Pie bacon at neilpie.co.uk
Tue Feb 26 00:08:30 UTC 2013

The only time I experience issues with this is when trying to get the meta-data into a column in the wp-admin listings table and making that column sortable. 

The MySQL joins that are used when WP queries data in the postmeta table will leave any non-existing rows out of the result set, whereas existing but 'empty' rows are returned. In the first case it can confuse the user by displaying different numbers of results than an unsorted search, and post totals don't match up.

If I'm doing_it_wrong then I'd love to know the right way to add postmeta into a sortable column in the admin tables - it will save me a real headache and what feels like an awful hack in one of my plugins that is certainly otherwise unnecessary.


On 20 Feb 2013, at 23:37, Steve Taylor wrote:

> A plugin I do (http://wordpress.org/extend/plugins/developers-custom-fields/)
> used to create DB records even if nothing was entered into the custom
> field. I changed it to not create a record if the value is empty, also
> to delete the existing record if it exists, but the new value entered
> is empty.
> No problems so far - I think in retrieving values you get the same
> result from an empty record as from no record.
> I'd be interested to hear if anyone else has alternate views on this.
> Cheers,
> Steve
> On 20 February 2013 16:05, Radi Varbanov <aparoph at gmail.com> wrote:
>> Hi Everyone,
>> First time posting here, so please bare with me :)
>> I am working on a site that is using the Yoast wpseo plugin and noticed
>> that even if you leave the SEO fields empty the plugin will store an empty
>> row into the wp_postmeta table. That made me think about how I should use
>> meta boxes.
>> So my question is:
>> When I use custom meta boxes should I also insert empty rows into the
>> wp_postmeta table or I should check to see if the fields is empty and if it
>> is, do not store anything? With small websites that my be not a problem but
>> when you have 50k+ posts and have ~10 custom post meta boxes and 11 form
>> the SEO plugin that adds up very fast.
>> Thanks,
>> Radi.
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers

More information about the wp-hackers mailing list