Этот JS вызывает функцию php
$(document).on("click", "#publication_content .thumb_3", function(e) {
e.preventDefault();
postContentId = $(this).attr('data-postid');
$.ajax({
url: "/wp-admin/admin-ajax.php",
method: 'post',
data: {
action: 'ajax_postcontent',
postContentId: postContentId
},
success: function (response) {
$("#publication_content").html(response);
}
});
});
Вот функция получения статьи через id сообщения
add_action('wp_ajax_nopriv_ajax_postcontent', 'ajax_postcontent' );
add_action('wp_ajax_ajax_postcontent', 'ajax_postcontent' );
function ajax_postcontent(){
// $_GLOBAL['postId'];
$postId = $_REQUEST['postContentId'];
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ){
$post = get_post($postId);
setup_postdata($post);
$postTempl = get_the_content();
wp_reset_postdata();
echo "<div class='article_2'>".$postTempl."</div>".next_posts_link('« Older Entries');
wp_die();
}
}
ajax_postcontent () находится в functions.php. Это необходимо для отображения нумерации страниц под пост статьи В нумерации страниц должна быть возможность перейти к предыдущей и следующей статье. Необходимо, чтобы нумерация страниц пролистывала статьи только в просматриваемой категории. Как это сделать?