Access table `wp_termmeta` with WP_query
-
Hi folks!
I am trying to perform a search using WP_Query. To give the search more performance I decided to use meta_tags on attachments. When the image is uploaded the action add_meta_tags writes a couple of meta tags in the table
wp_termmeta
. Works fine, even updating those meta tags works fine.Now I am trying to run a search using WP_query which looks like this:
// Query Args $args = array( /* Post params */ 'post_status' => 'inherit', 'post_type' => 'attachment', /* Meta key params */ 'meta_key' => 'country', 'meta_compare' => '=', 'meta_value' => 'chile', /* Sorting params */ 'order' => 'desc', 'orderby' => 'date', /* Pagination params */ 'nopaging' => false, 'posts_per_page' => 10, 'ignore_sticky_posts' => false, ); // The Query $the_query = new WP_Query( $args );
I thought that declaring the post_type as attachment would tell WP_Query to look in the table
wp_termmeta
, but that’s not happening. WP_Query is runing the meta_query on the table tablewp_postmeta
which is not what I want.Any suggestions. Tried a lot of stuff, but seems that I am overseeing something here.
[Moderator note: code fixed. Please wrap code in the backtick character or use the code button.]
- The topic ‘Access table `wp_termmeta` with WP_query’ is closed to new replies.