mardi 3 mars 2015

Query Posts that have Custom Taxonomy


I'm having trouble querying posts that have multiple tags from a custom taxonomy. For example, if I have a post called "Strawberry Splice," it has the Meal Types (custom taxonomy) "Gluten Free" and "Beverages."


When I filter the posts to look for "Gluten Free," "Strawberry Splice" shows up but when I search for "Beverages," there aren't any results. My query is only looking at the first term.


Take a look at http://ift.tt/1AAndHv


This is my partial code to generate the custom taxonomy:



$args = array(
'labels' => $labels,
'public' => true,
'show_in_nav_menus' => true,
'show_ui' => true,
'show_tagcloud' => true,
'show_admin_column' => false,
'hierarchical' => false,

'rewrite' => true,
'query_var' => true
);

register_taxonomy( 'meal_types', array('recipes'), $args );


This is my code for the query:



$mealtype = $_POST['mealtype'];

$args = array('post_type' => 'recipes', 'meal_types' => $mealtype, 'paged' => $paged);


How do I get it to look at all the terms?





Aucun commentaire:

Enregistrer un commentaire