이미 중간에 있습니다. 다음으로해야 할 일은 아약스 요청을 작성하고 PHP 콜백을 사용하여 다음 페이지를로드하는 것입니다. 코드는 다음과 같습니다. 주석에 특별한주의를 기울이십시오.
jQuery를
$.ajax({
url: data.ajax_url, // Localize this variable using Wordpress functions
type: 'post',
data: {
action: 'load_nextpage_page', // The name of php callback (function)
// Any other variables you may wish to pass
},
success: function(data) {
console.log(data);
// Here you can use the data returned by you PHP callback
}
});
PHP
내가이 일을 구축해야 할 수도 있습니다 모든 것을 설명했다
<?php
// your-javascript-file-handle is the one you use while enqueuing your JS files in wordpress. Use the same handle in following code
// to know more about localization visit https://developer.wordpress.org/reference/functions/wp_localize_script/
wp_localize_script('your-javascript-file-handle', 'data', array(
'ajax_url' => admin_url('admin-ajax.php'),
));
// AJAX callback handling
add_action('wp_ajax_load_nextpage_page', 'load_nextpage_page');
add_action('wp_ajax_nopriv_load_nextpage_page', 'load_nextpage_page');
function load_nextpage_page()
{
// Code for fetching next post here
// Remember you will need a variable to keep track of which post should be fetched next.
// Once you have fetched the right post
// you can echo the contents which will be passed as a reposnse to your ajax request.
}
. 나는 그것이 당신을 돕기를 바랍니다.
이것은 아마 ajax를 포함 할 것입니다. – developerwjk