WordPress Single Post Ajax Pagination

302
November 22, 2016, at 09:28 AM

I'm using the code here to try and paginate one post at a time by category but when I click on Older Posts it just fades and refreshes the current post. What am I doing wrong?

                    <div id="articles" class="contentbox">
                        <h2>Articles</h2>
                        <div id="posts-articles">
                            <?php
                                $new_query = new WP_Query();
                                $new_query->query('category_name=featurepost&showposts=1'.'&paged='.$paged);
                            ?>
                            <?php while ($new_query->have_posts()) : $new_query->the_post(); ?>
                            <a href="<?php the_permalink() ?>"><strong><?php the_title(); ?></strong></a>
                            <div class="alignleft"><?php the_post_thumbnail('thumbnail'); ?></div>
                            <?php the_excerpt() ?>
                            <?php endwhile; ?>
                            <div id="pagination">
                                <?php next_posts_link('&laquo; Older Entries', $new_query->max_num_pages) ?>
                                <?php previous_posts_link('Newer Entries &raquo;') ?>
                            </div>
                        </div><!-- end posts-articles -->
                        <script>
                        jQuery(function($) {
                            $('#posts-articles').on('click', '#pagination a', function(e){
                                e.preventDefault();
                                var link = $(this).attr('href');
                                $('#posts-articles').fadeOut(500, function(){
                                    $(this).load(link + ' #posts-articles', function() {
                                        $(this).fadeIn(500);
                                    });
                                });
                            });
                        });
                        </script>
                    </div>
Rent Charter Buses Company
READ ALSO
How to do pagination in my jsp pages

How to do pagination in my jsp pages

I have two jsp pages. One is searchData.

271
storing json element into javascript array

storing json element into javascript array

im using ajax retrieve database data with php and convert it to json.

372
Multiple toggle is not working for this() event

Multiple toggle is not working for this() event

While working with this code jsfiddle. .

244
How to access the width and height inside of this in jquery

How to access the width and height inside of this in jquery

I want to get the width and height of. more class and.

382