Last active
March 28, 2018 11:34
-
-
Save hawkidoki/97b9a90f151d29f327e59784e6c3f192 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Vérification que notre fichier est bien appelé via notre système | |
if(!$args = get_query_var('hwk_ajax_data')) | |
return; | |
// Data disponible: | |
// $args['id'] | |
// $args['template'] | |
// $args['cache'] | |
// $args['flush'] | |
// $args['param'] | |
// $args['interval'] | |
// Requête lourde ici | |
// Appel API, WP_Query etc... | |
$query = new WP_Query(array( | |
'post_type' => 'any', | |
'posts_per_page' => -1, | |
//'post__not_in' => array($args['param']), // On peut utiliser la valeur 'param' si celle-ci est définie. | |
)); | |
?> | |
<!-- Obligatoire: Création du container avec les données pour traitement pour l'ajax Ajax --> | |
<!-- La fonction hwk_ajax_template_data() utilise $args['id'], $args['interval'] & $args['param'] --> | |
<div <?php hwk_ajax_template_data(); ?>> | |
<!-- Affichage HTML du résultat --> | |
<?php if($query->have_posts()): ?> | |
<?php while($query->have_posts()): $query->the_post(); ?> | |
<?php // ... ?> | |
<?php endwhile; wp_reset_query(); ?> | |
<?php endif(); ?> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment