Answer the question
In order to leave comments, you need to log in
How to set LIMIT 3, 6 for WP_Query fetch?
Hello. I want to load records on Ajax when a button is pressed. As a result, the function looks like this
$startFrom = $_POST['startFrom'];
$postsPerPage = $_POST['postsPerPage'];
$latest_posts = new WP_Query(
[
'post_type' => 'post',
'posts_per_page' => $postsPerPage, //6
'offset' => $startFrom //3
]
);
[request] => SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE 1=1 AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'future' OR wp_posts.post_status = 'draft' OR wp_posts.post_status = 'pending' OR wp_posts.post_status = 'private') ORDER BY wp_posts.post_date DESC LIMIT 3, 6
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question