Skip to main content
deleted 70 characters in body
Source Link
Adam
  • 103
  • 7

WP_Query uses WP_Meta_Query and so I assumed (and. I thought I understood through research) that itthis calls the WP_Meta_Query::get_sql() to builddefine the meta query SQL.

Inside WP_Meta_Query::get_sql() which is where it applies the filter: get_meta_sql filter is applied.

I can't get thisthe get_meta_sql filter to fire.

I I thought it would fire with $var = new WP_Query($args); but it isn't. I

I need to alter the sql before it is run. A lot of sources specify this hook. I can't get it to work.

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.

  Alternatively - any suggestions on how to alter the WP_Query sql before it's run is appreciated.

I'm referencing:

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.

WP_Query uses WP_Meta_Query and so I assumed (and thought I understood through research) that it calls the WP_Meta_Query::get_sql() to build the meta query SQL.

Inside WP_Meta_Query::get_sql() is where it applies the filter: get_meta_sql

I can't get this 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.

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.

Alternatively - any suggestions on how to alter the WP_Query sql before it's run is appreciated.

I'm referencing:

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:

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.

Source Link
Adam
  • 103
  • 7

get_meta_sql hook is not firing

WP_Query uses WP_Meta_Query and so I assumed (and thought I understood through research) that it calls the WP_Meta_Query::get_sql() to build the meta query SQL.

Inside WP_Meta_Query::get_sql() is where it applies the filter: get_meta_sql

I can't get this 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.

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.

Alternatively - any suggestions on how to alter the WP_Query sql before it's run is appreciated.

I'm referencing: