Skip to content

Instantly share code, notes, and snippets.

@thiagotmendes
Last active July 30, 2019 20:53
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 thiagotmendes/87fb14e5f8fe1f227d59d9521d7b88c1 to your computer and use it in GitHub Desktop.
Save thiagotmendes/87fb14e5f8fe1f227d59d9521d7b88c1 to your computer and use it in GitHub Desktop.
<?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