jithin.k.k
jithin.k.k

Reputation: 65

previous_post_link problem

query_posts('category_name=News&showposts=1');

    <?php while (have_posts()) : the_post(); ?>

              <div>TOP NEWS <?php previous_post_link('%link', '>', TRUE) ; ?> </div>
              <?php $row = get_post_meta(get_the_id(), 'video');?>
              <?php echo $row[0]; ?>
                <div class="post" id="post-<?php the_ID(); ?>">
                    <a href="<?php the_permalink(); ?>"><h2><?php the_title(); ?></h2></a>
                    <h3>by <?php the_author(); ?></h3>
                </div>
                <?php the_content('Read more &raquo;'); ?>
                <?php previous_post_link('%link', 'Prev post in category', TRUE); ?>

    <?php endwhile;?>
    <?php wp_reset_query();?>
              <?php endif;?>

Am using these codes in my static page. when i click the previous_post_link , it goes to the single page to show the post. i need to show the post in the same static page. Anybody have any idea?

Upvotes: 2

Views: 422

Answers (1)

Tristar Web Design
Tristar Web Design

Reputation: 765

By default, that is what previous_post_link does. If you want to load the next post on the same page then you will need to look into AJAX. It sounds scary, but it is actually quite simple when using it in conjunction with jQuery. Have a look at the .get() function in jQuery.

You will need to make it so clicking the previous button sends a get request to jQuery, and fills a div with the content of that page.

Upvotes: 3

Related Questions