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
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
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