Hello I have a custom framework in Wordpress and I have two post-type Auto and Eventi.
I want that when I click on Category 'Eventi' Wordpress show the different post type in the same category.
Also I want that when i click on the Category 'Auto' Wordpress show only the custom post types with this category and so on.
I tried the following code but it only show one of the two post types and not both or the other post type.
For example if I click on a Evento that have the Category 'Eventi' it show all Eventi in the category.php page. But if I click on Auto and Category 'Auto' i get a page with no result.
Someone can explain me how to achieve this results?
function query_post_type($query) {
if( is_category() ) {
$post_type = get_query_var('post_type');
if($post_type)
$post_type = $post_type;
else
$post_type = array('nav_menu_item', 'post', 'eventi'); // don't forget nav_menu_item to allow menus to work!
$query->set('post_type',$post_type);
return $query;
}
}