Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hawkidoki/218f93e54209cb9654d3f35dc5041c93 to your computer and use it in GitHub Desktop.
Save hawkidoki/218f93e54209cb9654d3f35dc5041c93 to your computer and use it in GitHub Desktop.
<?php
// On vérifie que notre Template est bien appelé via hwk_loop()
// $loop a accès à toutes les arguments de hwk_loop()
if(!$loop = get_query_var('hwk_loop'))
return;
?>
<!-- Traitement de la boucle -->
<!-- Les résultats sont stockés dans $loop['result'] -->
<?php if($loop['result']->have_posts()): ?>
<?php while($loop['result']->have_posts()): $loop['result']->the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<a href="<?php the_permalink(); ?>">
<?php the_title(); ?>
</a>
</div>
<?php endwhile; wp_reset_postdata(); ?>
<!-- Si 'pagination' = true, alors gérer la pagination -->
<?php if($loop['pagination']){ ?>
<?php
echo paginate_links(array(
'current' => max(1, get_query_var('paged')),
'total' => $loop['result']->max_num_pages
));
?>
<?php } ?>
<!-- Pas de résultats -->
<?php else: ?>
<div>
Aucun résultat.
</div>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment