I'm using the Advanced Custom Fields plugin to add custom fields to my posts, but was wondering what is the best way to go about creating a filter box for the user to filter through posts.

enter image description here

I've been using the pre_get_posts action in WordPress to alter the meta query like so http://www.website.com/cars?type=saloon,couple,SUV. But I've found that when I start using multiple queries the website begins to hang and it's pretty slow.

Does anyone know if there's a better way to do this. I simply want my users to be able to filter through cars with relative ease. Am I going about this the wrong way?

Any help is appreciated. Thanks in advance!

  • Can you post your pre_get_posts action code?
    – Den Isahac
    Jun 26, 2017 at 18:18

1 Answer 1


Have you ever try to use 'custom taxonomy' to categorize the cars? I think taxonomy should be a more proper way to do this.

You could register car brands like:

// Register Custom Taxonomy
function wpse_131586_custom_taxonomy() {

    $labels = array(
        'name'                       => _x( 'Brands', 'Taxonomy General Name', 'wpse' ),
        'singular_name'              => _x( 'Brand', 'Taxonomy Singular Name', 'wpse' ),
        'menu_name'                  => __( 'Car Brands', 'wpse' ),
        'all_items'                  => __( 'All Items', 'wpse' ),
        'parent_item'                => __( 'Parent Item', 'wpse' ),
        'parent_item_colon'          => __( 'Parent Item:', 'wpse' ),
        'new_item_name'              => __( 'New Item Name', 'wpse' ),
        'add_new_item'               => __( 'Add New Item', 'wpse' ),
        'edit_item'                  => __( 'Edit Item', 'wpse' ),
        'update_item'                => __( 'Update Item', 'wpse' ),
        'separate_items_with_commas' => __( 'Separate items with commas', 'wpse' ),
        'search_items'               => __( 'Search Items', 'wpse' ),
        'add_or_remove_items'        => __( 'Add or remove items', 'wpse' ),
        'choose_from_most_used'      => __( 'Choose from the most used items', 'wpse' ),
        'not_found'                  => __( 'Not Found', 'wpse' ),
    $args = array(
        'labels'                     => $labels,
        'hierarchical'               => true,
        'public'                     => true,
        'show_ui'                    => true,
        'show_admin_column'          => true,
        'show_in_nav_menus'          => true,
        'show_tagcloud'              => true,
    //Change 'cars' to your post type accordingly
    register_taxonomy( 'car_brand', 'cars', $args );


// Hook into the 'init' action
add_action( 'init', 'wpse_131586_custom_taxonomy', 0 );

Hope you'll get the idea of registering a custom taxonomy for car types.

  • Thank you for this, however I'm unable to use custom taxonomies because my custom fields are a bit more intricate. Also, I need to use things like Select Menus and Checkboxes to make it as easy as possible for the admin to make changes to the cars.
    – realph
    Jan 29, 2014 at 6:18
  • I could understand that, I did the same thing as you before. But I found the search base on multiple meta values could be a disaster to performance... Have you tried the Meta Box plugin? It could let you use taxonomy but in the UI of select boxes or checkboxes. It might help!
    – 1fixdotio
    Jan 29, 2014 at 6:21
  • I'll check it out and give it a go. I really don't want to drop using Advanced Custom Fields as I find it's so powerful. It's just finding a way around this problem that doesn't impact performance. Javascript perhaps...?
    – realph
    Jan 29, 2014 at 6:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.