Home › Forums › General Issues › Filtering Archives Using Checkbox Custom Fields › Reply To: Filtering Archives Using Checkbox Custom Fields
@elliot Do you think this has anything to do with the serialized data the Checkbox Field outputs?
Some of my books are assigned to multiple Book Types, like so:
Book Title: Mums and Babies
Book Type:
Wondering if this is what’s causing the issue.
This is where I’m at currently:
add_action('pre_get_posts', 'my_pre_get_posts');
function my_pre_get_posts( $query ) {
if( is_admin() ) { return; }
$meta_query = $query->get('meta_query'); // get original meta query
if( isset($_GET['type']) ) {
$type = '"' . $_GET['type'] . '"';
$meta_query[] = array(
'key' => 'type',
'value' => $type,
'compare' => 'LIKE',
);
}
$query->set('meta_query', $meta_query); // update the meta query args
return; // always return
}
Works with one value, but not multiple values (.com/?type=women,babies):
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.