Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Quin452/6e4fcae4b2506f629362c9423e8d33f4 to your computer and use it in GitHub Desktop.
Save Quin452/6e4fcae4b2506f629362c9423e8d33f4 to your computer and use it in GitHub Desktop.
// What were searching for
$args = array(
'post_type' => $post_type,
'post_status' => 'publish'
);
// Now, if the category has been selected AND it doesn't equal the "show all" value
if(isset($_POST['category']) && $_POST['category'] != -1) {
// Explode the string into an array
$categories = array_map('intval', explode(',', $_POST['category']));
// Then load the POST array into the cat args
$args['category__in'] = $categories;
}
// Yep, a query
$query = new WP_Query($args);
// Loop through
if($query->have_posts()) {
// Do your thing here
}
@Quin452
Copy link
Author

Quin452 commented Jun 17, 2020

@User0123456789 do you have a link to your site I can look at?

@User0123456789
Copy link

User0123456789 commented Jun 17, 2020

@Quin452 it's still in my local env. But I can post the js code here. Wait a moment

@User0123456789
Copy link

@Quin452 please see here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment