Last active
July 30, 2019 20:53
-
-
Save thiagotmendes/87fb14e5f8fe1f227d59d9521d7b88c1 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 | |
// executa o load de questões na home do site | |
add_action('wp_ajax_load', 'load'); | |
add_action('wp_ajax_nopriv_load', 'load' ); // aparentemente não é obrigatorio utilizar este action | |
// funcao propriamente dita | |
function load(){ | |
$paged = $_GET['paged']; | |
$argQuestions = array( | |
'post_type' => 'posts', | |
'posts_per_page' => 6, | |
'paged' => $paged | |
); | |
$loopQuestions = get_posts($argQuestions); | |
if(!empty($loopQuestions)): | |
foreach ( $loopQuestions as $questions ) { setup_postdata($questions); | |
?> | |
<div class="col-md-4"> | |
<a href="<?= get_the_permalink($questions) ?>" class="link-box"> | |
<div class="box-questions"> | |
<h2> | |
<?= $questions->post_title ?> | |
</h2> | |
<i class="icon icon-plus-circle"></i> | |
</div> | |
</a> | |
</div> | |
<?php | |
} | |
else: | |
echo "<div class='col-md-12'>Nenhumpost encontrado</div>"; | |
endif; | |
die; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment