Home Forums General Issues Select posts by Category && Custom Field? Reply To: Select posts by Category && Custom Field?

  • Thanks, John, but I have to adapt this to my code to fully understand it:

    I have a range of jewellery (using a Custom Post Type = jewellery) that I separate by Category (using the built in Categories of WP) and Brands (using a custom field to select the brand in the custom post type).

    From that I create two separate drop downs: Category with values of IDs of categories, and Brands with values of strings.

    So if the user select a Brand from one of the selects and a Category from the other select, the code you provide should look like this, right:

    'post_type' => 'jewellery',
    'tax_query' => array(
    			'taxonomy' => 'category',
    			'terms' => array( $category ) // <-- THIS I GET FROM $_GET['c']
    	'meta_query' => array(
    		'key' => 'select_brand', // <-- WHAT DO I PUT HERE (THE CUSTOM FIELD VALUE, this is what I named it.)
    		'value' => $brand // <-- THIS I GET FROM $_GET['b']