php - AJAX loads same posts every time in wordpress loop -
i needed pagination wordpress ajax-powered. when visitor clicks "older entries"
, page not have reloaded show older posts.
i've serched , found solution here. problem is, loads same post everytime.
here query:
<ul class="recipe-list"> <?php $home_rcp = $redux_imd['home_rcp']; $rcpquery = new wp_query(array( 'cat'=> $home_rcp, 'posts_per_page' => 4 )); while ($rcpquery->have_posts()) : $rcpquery->the_post(); ?> <li> <?php the_post_thumbnail('recipe-thumb'); ?> <div class="caption"> <div class="blur"></div> <div class="caption-text"> <div class="post-title"> <h5><?php the_title() ?></h5> </div> <div class="recipe-home-meta"> <p>posted on <?php the_time('y/m/d'); ?> <?php the_author(); ?> </p> </div> <a href="<?php the_permalink() ?>" rel="bookmark"> see recipe </a> </div> </div> </li> <?php endwhile; ?> <div id="pagination"> <?php next_posts_link( '« older entries', $rcpquery->max_num_pages) ?> <?php previous_posts_link( 'newer entries »') ?> </div> </ul>
and here ajax-code:
$('.recipe-list').on('click', '#pagination a', function (e) { e.preventdefault(); var link = $(this).attr('href'); $('.recipe-list').fadeout(500, function () { $(this).load(link + ' .recipe-list', function () { $(this).fadein(500); }); }); });
what i'm doing wrong here?
$ redux_imd
in first line of php-code definately throw error. , won't receive page.
Comments
Post a Comment