Wordpress Query on custom fields -


my site has woocommerce plugin, post_type product. each product has several custom fields used plugin (compare products pro).

now query products url eg: www.domain.com/?post_type=product&custom_field=value

is possible? , how?

any highly appriciated!

you add query arguments:

'post_type' => $_get['post_type'], 'meta_query' => array(     array(        'key' => '_woo_compare_field-',        'value' => $_get['_woo_compare_field-'],        'compare' => '=',     )  ), 

but static, not work different meta key value pairs.

you assign them array , append array

    $meta_queries = array(         'relation' => 'and',     );      foreach($_get $key => $value) {         $result = array(             'key' => $key,             'value' => $value,             'compare' => '=',         );         $meta_queries[] = $result;     } 

and append $meta_queries array wordpress query arguments.

but means variables used meta key value pairs. can ofcourse write logic never pretty


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -