WP Query by variable custom field

Question

I have a CPT which contains one large field group (‘Global’), and two other field groups which contain ACF Clone Fields (‘NJ’ and ‘PA’). The fields in NJ and PA are identical to Global, except that they are prefixed with nj_ and pa_.

I also have a separate radio button field, where I specify which is the primary location (‘primary_geo’) for that particular post. This is effective insofar as it enables me to control the information shown on the post itself.

My problem is this: when I use WP Query to create a list of these posts, I’d like to filter and sort the posts according to the data in the field prefixed with the primary_geo. Meaning sometimes pa_field will be compared with nj_field. But because it’s outside the loop, I can’t get that value.

Is there a way for me to achieve what I’m looking for?

0
, Alex Smooth Websites 1 year 2020-07-26T06:10:26-05:00 0 Answers 40 views 0

Leave an answer

Browse
Browse