Création d'une page d'accueil

Par Tony Richer, il y a 10 ans


Bonjour, je solicite votre aide car je suis dans l'impasse !
J'utilise la fonction WP_Query(); de wordpress mais je n'arrive pas à afficher mes derniers articles comme je le voudrais !
voici mon code :

<div class="grid grid-pad no-top"> <div class="col-1-3 tri-clear wow animated fadeInUp animated" data-wow-delay="0.25s" style="visibility: visible; animation-delay: 0.25s; -webkit-animation-delay: 0.25s; animation-name: fadeInUp; -webkit-animation-name: fadeInUp;"> <?php $recentPosts = new WP_Query(); $recentPosts->query('showposts=3'); ?> <?php while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?> <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" ><?php the_post_thumbnail(); ?></a> <a href="<?php the_permalink() ?>" rel="bookmark"><h5><?php the_title(); ?></h5></a> <p><?php the_excerpt(); ?><a href="<?php the_permalink() ?>">Lire la suite</a></p> <?php endwhile; ?> </div><!-- col-1-3 --> </div><!-- grid -->

Le problème c'est que mes derniers articles s'affichent dans la même div. Pourtant je voudrais que chaque article créer une div :

<div class="col-1-3 tri-clear wow animated fadeInUp animated" data-wow-delay="0.25s" style="visibility: visible; animation-delay: 0.25s; -webkit-animation-delay: 0.25s; animation-name: fadeInUp; -webkit-animation-name: fadeInUp;">

et se glisse gentiment à l'intérieur ! Du coup le résultat est vertical !

Quelqu'un peut m'aider ? :)

4 réponses

Lartak, il y a 10 ans

Bonjour.
Il te suffit d'intégrer la div correspondante dans le while et non à l'extérieur :

<div class="grid grid-pad no-top"> <?php $recentPosts = new WP_Query(); $recentPosts->query('showposts=3'); ?> <?php while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?> <div class="col-1-3 tri-clear wow animated fadeInUp animated" data-wow-delay="0.25s" style="visibility: visible; animation-delay: 0.25s; -webkit-animation-delay: 0.25s; animation-name: fadeInUp; -webkit-animation-name: fadeInUp;"> <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" ><?php the_post_thumbnail(); ?></a> <a href="<?php the_permalink(); ?>" rel="bookmark"><h5><?php the_title(); ?></h5></a> <p><?php the_excerpt(); ?><a href="<?php the_permalink() ?>">Lire la suite</a></p> </div><!-- col-1-3 --> <?php endwhile; ?> </div><!-- grid -->
Tony Richer, il y a 10 ans

Merci beaucoup :)

Lartak, il y a 10 ans

De rien, avec plaisir. :)

Aleex, il y a 10 ans

Ah merci bien ca va me servir aussi