WordPress-Developers-Custom-Fields icon indicating copy to clipboard operation
WordPress-Developers-Custom-Fields copied to clipboard

slt_cf_get_posts_by_custom_first() is broken

Open gyrus opened this issue 13 years ago • 2 comments

This function is certainly broken, returning the query object instead of just the posts.

It may even be fundamentally broken - the usort() seems to just override the sorting by custom field.

Not sure whether to fix it or remove it?

gyrus avatar Jan 11 '12 16:01 gyrus

I was just trying use this, came here to file a bug report. Obviously I vote to fix ;)

tomvdv avatar Jan 13 '12 15:01 tomvdv

I've had a quick look at this and I think it needs re-doing to make it work. There was one obvious error in that the $slt_cf_second_orderby and $slt_cf_second_order vars weren't declared as global in the slt_cf_order_posts() helper function.

But I think the approach is flawed. Doing it the current way, the usort() will simply erase the meta sorting. I think we need something that gets the ordering parameters right into the SQL. Almost certainly doable, but it's not something that's urgent for me. I imagine it could be easily done "alongside" the plugin by hooking in the query.

I'm putting the code on GitHub now, so maybe someone else can contribute a working version of the function?

gyrus avatar Feb 19 '12 14:02 gyrus