L’altro giorno lavorando su wordpress non riuscivo ad ottenere, sul frontend, i post di tipo diverso sotto un’unica categoria.
Ho trovato un filtro da aggiungere al file delle funzioni (functions.php) del tema, ma questo mi faceva sparire il menu.
Dopo uno strenuante debug ho modificato la funzione per giungere alla versione finale che riporto qui di seguito:

[php]
add_filter(‘pre_get_posts’, ‘query_post_type’);
function query_post_type($query) {
if(
(is_category() || is_tag() || is_search())
and
$query->query_vars[post_type]!=’nav_menu_item’)
{
$post_type = get_query_var(‘post_type’);
if($post_type)
$post_type = $post_type;
else // replace custom post type to your custom post type
$post_type = array(‘post’,’portfolio’);
$query->set(‘post_type’,$post_type);
return $query;
}
return $query;
}
[/php]
In pratica, prima di ogni query eseguita dal core di wordpress, controllo che stia cercando i post di una categoria, di un tag o stia effettuando una ricerca e che non sia la query per la ricerca delle voci del menu.
Questo poiché, in wordpress, tutto è considerato un post anche le voci di menu, gli attachments etc..