Home › Forums › General Issues › sql query › Reply To: sql query
I think that’s a pretty big ask. Not to mention we don’t know how many custom fields you have or what they’re called!
If I were you, I’d look at the wp_query
I’d ensure you query the correct post type and I’d look the OR operator, like this example:
$args = array(
'post_type' => 'product',
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'color',
'value' => 'blue',
'compare' => 'NOT LIKE',
),
array(
'key' => 'price',
'value' => array( 20, 100 ),
'type' => 'numeric',
'compare' => 'BETWEEN',
),
),
);
$query = new WP_Query( $args );
Once you’ve added ALL of your possible custom fields and the output displays something, you could look to output your wp_query in SQL using:
$customPosts = new WP_Query($yourArgs);
echo "Last SQL-Query: {$customPosts->request}";
That hopefully will give you the SQL you need.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.