Answer the question
In order to leave comments, you need to log in
Ajax loading posts in custom WP theme?
Good afternoon, tell me how you can load new posts in place of old ones (when clicking on pagination links)? I output some posts in a cycle
$current_page = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'posts_per_page' => 2,
'cat' => 2,
'offset' => 0,
'order' => 'ASC',
'paged' => $current_page
);
$query = new WP_Query( $args );
while ( $query->have_posts() ) {
$query->the_post();
$good = get_field('good');
foreach ($good as $item) {
?>
<!-- Здесь выводится товар -->
<?
}
}
wp_reset_postdata(); // сброс
?>
offset
and HTML'ить
its in the block where the goods should be (I didn’t come up with a better option :-( ) ajax
a request to the file admin-ajax.php
and so that it generates a new set of goods for me and returned it as an answer to js
the ajax request function, but I don’t understand how to make this php function... can someone give a link or suggest an idea Answer the question
In order to leave comments, you need to log in
Didn't get the point. You just need to chew ajax how to create in wp? Well, here is a link to kama , there is nowhere to tell in more detail how ajax requests are created in wp. Or was the issue something else?
Create a layer with an id like ajax_result. Assign success to ajax_result. Regarding the creation, see the link to kama
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question