I'm filtering posts by a custom field value and it works if its just one but I want to have it so that i can enter the different custom field values multiple times in a post and have it appear in multiple queries. This is what the WP_Query looks like:

$args = array(
    'posts_per_page' => '10',
    'post_type' => 'products',
    'meta_key' => 'Product Category',
    'meta_value' => 'INSPECTION',
    'order' => 'asc',
    'paged' => $paged
$the_query = new WP_query($args);

so essentially I want to have product category entered into a post multiple times with different values and for it to appear in multiple queries. At the moment it will only appear in one. I realize i can use specific custom post taxonomy and categories but I want to try and avoid that

  • Why do you want to avoid taxonomies? They're designed specifically for what you're trying to do. Nov 15, 2018 at 9:37
  • I am already using taxonomies for another purposes on this custom post type
    – Zayd Bhyat
    Nov 15, 2018 at 9:43
  • also the staff using this system and some our own internal scripts use the query results for some data processing. Anyway if there is no other way ill use custom taxonomies
    – Zayd Bhyat
    Nov 15, 2018 at 9:45
  • You can have more than one custom taxonomy. No reason you can't have another one. No point reinventing the wheel. Nov 15, 2018 at 10:07

1 Answer 1


Took the advice and decided not to reinvent the wheel. Created a taxonomy specific for products called Product categories. Added the following code to my functions.php.

add_action('init', 'products_categories', 0);

function products_categories(){
$labels = array ('name' => _x('Product Categories','taxonomy general name'),
                'singular_name' =>_x('Product Category','taxonomy singular name'),
                'serch_items' => __('Search Product Categories'),
                'popular_items' => ('Popular Product Categories'),
                'all_items' => __('All Product Categories'),
                'parent_item' => null,
                'parent_item_colon' => null,
                'edit_item' => __('Edit Product Category'),
                'update_item' => __('Update Product Category'),
                'add_new_item' => __('Add Product Category'),
                'new_item_name' => __('New Product Category'),
                'separate_items_with_commas' => __('Seperate Product Categories with commas'),
                'add_or_remove_items' => __('Add or remove Product Categories'),
                'choose_from_most_used' => __('Most Used Product Categories'),
                'menu_name' => __('Product Categories'),

register_taxonomy('product_categories', 'products', array(
'hierarchical' => false,
    'labels' => $labels,
    'show_ui' => true,
    'show_admin_column' => true,
    'update_count_callback' => '_update_post_term_count',
    'query_var' => true,
    'rewrite' => array( 'slug' => 'product_category' ),

Now all I have to do is retrain my staff, rewrite some of my internal scripts and redo my queries T_T

Your Answer

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

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