• I am adding couple of extra inputs to the edit.php filters via

    add_action(‘manage_posts_extra_tablenav’, array($this, ‘add_view_search_orders’));

    I’m using the add_filter(‘parse_query’, array($this, ‘parse_sku_price’)); filter to try and modify the query, BUT to achieve what I want, I need to be able to use $wpdb and write my own custom query with subqueries.

    How do I go about creating a brand new query instead of modifying the existing $query object via $meta_query and $query->set( ‘meta_query’, $meta_query );

    Essentially when someone filters, I want to start a whole new query using $wpdb.

    Thank You

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    You can replace the SQL that WP comes up with with your own preference through the “posts_request” filter. You don’t need the global $wpdb, WP will pass on your SQL for you.

    But it’s rather wasteful to let WP parse the request and do all this other processing, only to throw it all out and do your own thing. Why not just make a custom query from the start? I guess if you need data from global $wp_query in order to do what you want to do, it makes sense to use “posts_request”.

Viewing 1 replies (of 1 total)
  • The topic ‘Custom Query For Filter On edit.php Post Listing’ is closed to new replies.