WP_Query
uses WP_Meta_Query
. I thought this calls the WP_Meta_Query::get_sql()
to define the meta query SQL which is where the get_meta_sql
filter is applied.
I can't get the get_meta_sql
filter to fire. I thought it would fire with $var = new WP_Query($args);
but it isn't.
I need to alter the sql before it is run. A lot of sources specify this hook. I can't get it to work. Alternatively - any suggestions on how to alter the WP_Query sql before it's run is appreciated.
I'm referencing:
- https://developer.wordpress.org/reference/hooks/get_meta_sql/
- https://developer.wordpress.org/reference/classes/wp_query/
- https://weplugins.com/wordpress/how-to-use-get_meta_sql-filter-in-wordpress/
- Query to get result by Title or Meta along with tax_query parameter
- https://stackoverflow.com/questions/43734845/how-to-give-or-relation-in-tax-query-and-meta-query-wordpress
The actual code is long/complicated, I can't even get it to fire with dummy code in a blank plugin. Just trying to figure out why this hook won't fire where I'm expecting it to.
post_clauses
hook for SQL modifications.