WordPress.org

Ready to get started?Download WordPress

Forums

Load previous/next posts without whole page reload (2 posts)

  1. incite
    Member
    Posted 5 years ago #

    I have limited the amount of posts displayed from a certain category. This can be seen in the code below (ive cut out a bit of code to shorten it for this post). Anyway so what i would like to happen is when the next and previous links are clicked to display older/newer post ids i would like it to load these without having to reload the whole site.

    Im new to wordpress and this is a learning curve, i realise this may require some use of ajax or jQuery. All im after is point in the right direction.

    <?php
    $page_num = $paged;
    if ($pagenum='') $pagenum =1;
    query_posts('cat=5&showposts=7&paged='.$page_num); ?>
                   	<?php if (have_posts()) : ?>
    		<?php while (have_posts()) : the_post(); ?>   
    
    <!-- item -->
    <div class="menutest"><h1><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h1></div>
    <!-- end item -->
    
    <?php endwhile ; ?>
    <div class="navigation">
    <div class="alignleft"><?php next_posts_link('&laquo; Previous Entries') ?></div>
    <div class="alignright"><?php previous_posts_link('Next Entries &raquo;') ?></div><p> </p></div>
    
    <?php endif; ?>

    Thank you very much in advance!

  2. Austin Matzko
    Member
    Posted 5 years ago #

    Something like this should get you started:

    jQuery('.navigation a').click(function() {
         jQuery('.menutest').load(jQuery(this).attr('href') + " .menutest");
    });

Topic Closed

This topic has been closed to new replies.

About this Topic