someone there help me and solved the problem.
It works.
Cool.
Thks guys.
Details :
First – I remove this code from function.php
function namespace_add_custom_types( $query ) {
if( ( is_tag() || is_category() ) && empty( $query->query_vars['suppress_filters'] ) ) {
$query->set( 'post_type', array(
'post', 'projets', 'disques', 'notices', 'main_menu', 'top_menu'
));
return $query;
}
}
add_filter( 'pre_get_posts', 'namespace_add_custom_types' );
(I used this to get my custom post type in category and tag template pages. It also prevent nav menu to disappear. Here I don’t need it anymore, I will use multiple loops.)
Second – Use this code in category.php and tag.php :
<?php
$current_cat = get_query_var('cat');
// for tags use 'tag'
// $current_tag = get_query_var('tag');
// --- First Loop --- Notices
$args = array(
'cat' => $current_cat,
//'tag' => $current_tag,
'post_type' => 'notices',
);
$the_first_query = new WP_Query( $args );
// The Loop
while ( $the_first_query->have_posts() ) : $the_first_query->the_post();?>
<?php the_title(); ?>
<?php the_post_thumbnail(); ?>
<?php the_excerpt(); ?>
<?php endwhile;
// Reset Post Data
wp_reset_postdata();
// END --- First Loop ---
// --- Second Loop --- Projets
$args = array(
'cat' => $current_cat,
// 'tag' => $current_tag,
'post_type' => 'projets',
);
$the_second_query = new WP_Query( $args );
// The Loop
while ( $the_second_query->have_posts() ) : $the_second_query->the_post();?>
<?php the_title(); ?>
<?php the_post_thumbnail(); ?>
<?php the_excerpt(); ?>
<?php endwhile;
// Reset Post Data
wp_reset_postdata();
// END --- Second Loop ---
// --- Third Loop --- Disques
$args = array(
'cat' => $current_cat,
// 'tag' => $current_tag,
'post_type' => 'disques',
);
$the_third_query = new WP_Query( $args );
// The Loop
while ( $the_third_query->have_posts() ) : $the_third_query->the_post();?>
<?php the_title(); ?>
<?php the_post_thumbnail(); ?>
<?php the_excerpt(); ?>
<?php endwhile;
// Reset Post Data
wp_reset_postdata();
// END --- Third Loop ---
?>
The bad thing is that breaks pagination… but in my case, it’s not important.
Thks to keesiemeijer from wordpress.org Forums for original answer.