how to refresh div on template part?

i’m keep learning about wordpress development and i’ve developed this template-part and loop and i need that entire div#dreams-gallery refresh after a period of time, let’s say 10 seconds.

Here’s my code:

<?php

$args=array(
    'post_type'=>'sonhos', 
    'orderby'=>'rand', 
    'posts_per_page'=>'36'
);

$dreams_lightbox_posts = new WP_Query($args);
$dreams_lightbox_posts = $dreams_lightbox_posts->posts;
?>

<section role="dreams-wrapper">
    <div id="dreams-gallery" class="container-fluid">

        <?php if (count($dreams_lightbox_posts) > 0): ?>

            <div class="row">

            <?php foreach ($dreams_lightbox_posts as $key => $post ): ?>
                <?php if ($key % 12 == 0 && $key > 0): ?>

                    </div>
                    <div class="row">

                <?php endif ?>

                <div class="col dreams-thumb" data-title="<?= $post->post_title ?>" data-intro="<?php the_field('intro-sonho', $post->ID); ?>" data-sonho="<?php the_field('data-sonho', $post->ID); ?>" data-parceirosonho="<?php the_field('parceiro-sonho', $post->ID); ?>" data-frasesonho="<?php the_field('frase-sonho', $post->ID); ?>"> 
                    <a title="<?= $post->post_title ?>" href="#dreams-gallery">
                        <img class="img-fluid" src="<?php echo the_field('imagem-sonho', $post->ID) ?>">
                    </a>
                </div>

            <?php endforeach ?>

        <?php else: ?>

            <p>Não existem fotos...</p> 

        <?php endif ?>

    </div>  

</div>  


<!-- Modal dialog -->
<div tabindex="-1" class="modal fade" id="myModal" role="dialog">
    <div class="modal-dialog">
        <div class="modal-content">
              <div class="modal-header">
                <h3 class="modal-title"></h3>
                <br>
                <p class="modal-intro"></p>
                <button class="close" type="button" data-dismiss="modal">×</button>
            </div>
            <div class="modal-body">

            </div><!--/ modal-body -->
            <div class="modal-footer">
                <div class="modal-footer-info">
                    <time><strong>Realizado a: </strong><span id="sonho"></span></time>
                    <h4><strong>Sonho patrocinado por: </strong><br><span id="parceiro_sonho"></span></h4>
                    <p id="frase_sonho"></p>
                </div>
                <button class="btn btn-default" data-dismiss="modal">Fechar</button>
            </div>
         </div><!--/ modal-content -->
    </div><!--/ modal-dialog -->
</div>

Any ideas? Thanks.

Read more here: how to refresh div on template part?

Leave a Reply

Your email address will not be published. Required fields are marked *