function comm(){
$p_id = ( $_POST['spd'] );
$args = array(
'posts_per_page' => -1,
'p' => $p_id
);
$yy_query = new WP_Query($args);
while ( $yy_query->have_posts() ) {
$yy_query->the_post();
global $withcomments;
$withcomments = true;
comments_template();
}
wp_die();
}
add_action('wp_ajax_mycomm', 'comm');
add_action('wp_ajax_nopriv_mycomm', 'comm');
---
$('.seecomments').click(function(){
$.ajax({
url: ajaxurl,
type: 'POST',
beforeSend: (function(){
$('.comment_template').html('Загрузка..');
}),
data: ({
action: 'mycomm',
spd: send_post_id
}),
success: function(data){
$('.comment_template').html(data);
}
})
});
---
В single.php
//code...
<div class="seecomments">показать комменты</div>
<script>
var send_post_id = <?php the_ID(); ?>;
</script>
//code..