Home › Forums › General Issues › Select posts by Category && Custom Field? › Reply To: Select posts by Category && Custom Field?
Thanks, John, but I have to adapt this to my code to fully understand it:
I have a range of jewellery (using a Custom Post Type = jewellery) that I separate by Category (using the built in Categories of WP) and Brands (using a custom field to select the brand in the custom post type).
From that I create two separate drop downs: Category with values of IDs of categories, and Brands with values of strings.
So if the user select a Brand from one of the selects and a Category from the other select, the code you provide should look like this, right:
'post_type' => 'jewellery',
'tax_query' => array(
array(
'taxonomy' => 'category',
'terms' => array( $category ) // <-- THIS I GET FROM $_GET['c']
)
),
'meta_query' => array(
array(
'key' => 'select_brand', // <-- WHAT DO I PUT HERE (THE CUSTOM FIELD VALUE, this is what I named it.)
'value' => $brand // <-- THIS I GET FROM $_GET['b']
)
)
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.