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:
- Will that result in a proper order if there is no row in your custom table for some posts?
- 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.
Related Posts:
- Return only Count from a wp_query request?
- Use REGEXP in WP_Query meta_query key
- find a random blogid across my multisite network that has at least one post published
- Get posts by menu ID
- Slow SQL_CALC_FOUND_ROWS Query
- Should close $wpdb via $wpdb->close()
- Get the Plugin Which Triggered a MySql Query in WordPress?
- How To Get Some Data From WordPress Database Using WordPress $wpdb Query?
- Mysql query LIKE not working
- wpdb custom post_type problem
- why update and delete query not worked in custom table?
- How to implement a new row_count method in WordPress?
- wp_Qwery works to slow
- Query most popular terms by taxonomy over 2 week period
- Which is faster wpdb & get_row or wp_query & ge_post_meta?
- How to access custom WordPress database tables
- List of ways to access WordPress database?
- Specify strict ‘order by’ in WordPress query
- how to get Nearby zipcode
- Does WordPress have something like Drupal’s DB API?
- WP_Query with page_ids in arguments without a result
- get_var is neither a string, integer, or array …?
- Why last row deleted when refresh page
- How to get user avatar via WPDB
- Fix wp_term_relationships slow query in get_posts
- Sorting query_posts() with a complex orderby filter
- Track write actions to the database
- Include post_status check within $wpdb query
- wpdb get_results() returns only 2 rows
- WP_Query always returning the last custom post
- Optimising amount of calls to custom fields
- Different sql queries count indicator on the main page [closed]
- SQL query into to WP query
- How to return number of found rows from SELECT query
- Order by DESC, ASC in custom WP_Query
- $wpdb->delete column values IN ARRAY()?
- Use WP_Query with a custom SQL query
- How to make an activities stream mixing posts and comments?
- Why does dbDelta() not catch MysqlErrors?
- SQL query equivalent to WP User Query
- Group posts by meta_key
- Would this post meta be better added to the post table rather than post_meta table
- What causes the “max_user_connections” warning on WordPress frontend?
- Order By Multiple Meta Fields
- meta_query on a date range using an array of values
- WP_Query Performance Issues with meta_query
- Remove ellipsis from the excerpt retrieved using get_the_excerpt()
- Version upgrade: can my plugin filter the SQL statements issued during a database upgrade?
- Use ‘parse_query’ filter to show posts that from multiple criteria
- Modifying the Search Results
- How to correctly pass values to wpdb->prepare()?
- How to use filter hook “the_posts” with a function that refers to $this?
- Hide Administrators From User List except current user (administrator)
- Advanced SELECT query with condtional statements
- How to create database table, add data, update and delete using wpdb via plugins?
- Custom Query num_rows returns wrong amount
- How can I filter by slug depending on language selection
- Using hook to use DISTINCT in a wp_query
- pagination with ‘no_found_rows’ => true,
- Filtering posts from different categories into different section by doing WP_Query only once
- Redirecting to old domain after migration website
- Update results, Before deleting the related category [closed]
- querying data via $wpdb and get_row
- Slow WP_Query with ‘OR’ on meta_query
- Add posts to WP Query object
- Ajax future single post query doesn’t work when NOT logged in
- Conditional sorting with variable using WP Query
- WP User Query with Custom Fields and Search Results
- I can’t update my data through $wpdb
- WP_Query – How to get all posts of specific days of week by custom field date?
- Multiple wp_query on archive page
- Retrieve select tag custom values from array and display them in current page with wp_query?
- How to use a dropdown to filter posts by custom field
- Retrieve data from wordpress db via input and put those result in dropdown
- How to connect and insert data in database of wordpress?
- Function to retrieve IDs of posts, cache results, and improve wp_query
- Filtering by multiple conditions in the loop
- Custom post type – filter content by custom meta box content
- Passing in MySQL prepare statement parameter separately throwing error
- Custom meta_query order for Elementor based on post meta key [closed]
- Any way to use FETCH_KEY_PAIR with $wpdb?
- “BS_” rows in postmeta table
- INNER JOIN custom tables – SQL Query
- use mysql variable in a $wpdb->query to reindex a column?
- WordPress Database Query works in phpMyAdmin but not in the code
- WP Query filters active on wrong query
- Query postmeta based on meta_value, return array of post_id
- Gather same custom field values in one value in a select tag with wp_query
- In which file to use $wpdb and its functions for database operations and queries in wordpress?
- pull data from wordpress database
- How To connect to the same WordPress database with different database user
- What argument does my function need to echo get_results() query results
- Fetch only categorized posts
- complex query question
- option select form always deleting the sql query
- Fire query on ajax post url page
- how to add limit records in wordpress query
- WP_Query by meta key not returning any posts
- List categories using WP_Query
- Bulk delete comments, foreach loop