Order by custom table and multiplication

There’s nothing wrong with it from WPs point of view. If you want to join posts with your own table and change the way of ordering, then that’s the way to do it.

The only thing is a little bit tricky, I guess, is that you use posts_join_paged and not posts_join – it can make it a little bit harder to debug if something goes wrong, but it also makes it a little bit more optimal, so there’s nothing wrong with this.

The are two things that concern me a little bit with this approach:

  1. Will that result in a proper order if there is no row in your custom table for some posts?
  2. Wouldn’t it be nicer for DB to store that multiplication result already computed – ordering by value of o column is nicer for DB than ordering by computed value.