Les boucles WordPress ne sont pas forcément simples à personnaliser, voici quelques exemples de codes glanés sur la toile:
Always use get_posts … . Remove the arguments that you don’t use on the array below.
$args = array(
'posts_per_page' => 5000,
'offset' => 0,
'category' => ,
'orderby' => 'post_date',
'order' => 'ASC',
'include' => ,
'exclude' => ,
'meta_key' => ,
'meta_value' => ,
'post_type' => 'post',
'post_mime_type' => ,
'post_parent' => ,
'post_status' => 'publish',
'suppress_filters' => true );
$posts = get_posts($args);
foreach ($posts as $post) :
?>
Autre exemple:
https://codex.wordpress.org/Category_Templates
You can also use Conditional_Tags in order to create archives that respond to conditions set by the URL or context. For instance, if you would like to ensure that when a user visits http://yourblog.com/2008/02/ it will show posts from February of 2008 first, simply add this code to your archive.php file.
have_posts() ) :
$the_query->the_post();
echo '
' . get_the_title() . '
';
endwhile;
/* Restore original Post Data
* NB: Because we are using new WP_Query we aren't stomping on the
* original $wp_query and it does not need to be reset.
*/
wp_reset_postdata();
?>