WordPress单一后Ajax分页

时间:2015-10-07 07:10:54

标签: php jquery ajax wordpress pagination

我正在使用代码here按类别一次尝试对一个帖子进行分页,但是当我点击旧帖子时,它只会淡化并刷新当前帖子。我做错了什么?

                    <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>

0 个答案:

没有答案