WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] previous_post_link not working (3 posts)

  1. trb310
    Member
    Posted 5 years ago #

    The website: http://providencedailydose.com
    I have two loops on the main the first use wp_query to display one post from a certain category and main loop uses query_post to display the rest of the post excluding the category from the first loop.

    loop 1:

    <?php
      $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
      ?>
      <?php if (have_posts()) : ?>
      <?php //query_posts('paged='.$paged);
    $temp = $wp_query;
    $wp_query= null;
       $wp_query = new WP_Query();
       $wp_query->query('category_name=featured&showposts=1'.'&paged='.$paged);
    ?>
      <?php while (have_posts()) : the_post(); ?>
      <div id="feature">
        <div id="feature-ad"><img src="<?php bloginfo('template_directory');?>/images/728x90_ad.png" alt="728x90 banner ad" width="728" height="90" name="728x90" /></div>
        <div class="post" id="post-<?php the_ID(); ?>">
          <p class="cats">
            <?php $category = get_the_category(); ?>
            filed under: <a href="/topics/<?php echo $category[0]->category_nicename; ?>/" name="<?php echo $category[0]->cat_name; ?>"><?php echo $category[0]->cat_name; ?></a> | <a href="/topics/<?php echo $category[1]->category_nicename; ?>/" name="<?php echo $category[1]->cat_name; ?>"><?php echo $category[1]->cat_name; ?></a></p>
          <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
            <?php the_title(); ?>
            </a></h2>
          <p class="date-stamp">
            <?php the_time('gA') ?>
            ON
            <?php the_time ('d/m/Y') ?>
            <br />
            BY
            <?php the_author_posts_link(); ?>
          </p>
          <div class="entry">
            <?php the_content('<span class="more-link">more &raquo;</span>'); ?>
          </div>
          <p class="postmetadata">
            <?php edit_post_link('Edit', '', ' | '); ?>
            <?php comments_popup_link('leave a comment on this post »', 'one comment »', '% comments »'); ?>
          </p>
        </div>
      </div>
      <?php endwhile; ?>
      <?php endif; ?>
      <?php $wp_query = null; $wp_query = $temp;?>

    loop 2:

    <?php if (have_posts()) : ?>
        <?php query_posts('cat=-2032'); ?>
        <?php while (have_posts()) : the_post(); ?>
        <div class="post" id="post-<?php the_ID(); ?>">
          <p class="cats">
            <?php $category = get_the_category(); ?>
            filed under: <a href="/topics/<?php echo $category[0]->category_nicename; ?>/" name="<?php echo $category[0]->cat_name; ?>"><?php echo $category[0]->cat_name; ?></a> | <a href="/topics/<?php echo $category[1]->category_nicename; ?>/" name="<?php echo $category[1]->cat_name; ?>"><?php echo $category[1]->cat_name; ?></a></p>
          <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
            <?php the_title(); ?>
            </a></h2>
          <p class="date-stamp">
            <?php the_time('gA') ?>
            ON
            <?php the_time ('d/m/Y') ?>
            <br />
            BY
            <?php the_author_posts_link(); ?>
          </p>
          <div class="entry">
            <?php the_content('<span class="more-link">more &raquo;</span>'); ?>
          </div>
          <p class="postmetadata">
            <?php edit_post_link('Edit', '', ' | '); ?>
            <?php comments_popup_link('leave a comment on this post »', 'one comment »', '% comments »'); ?>
          </p>
          <hr  />
        </div>
        <?php endwhile; ?>
        <div class="navigation">
          <div class="alignleft">
            <?php next_posts_link('&laquo; Older Entries') ?>
          </div>
          <div class="alignright">
            <?php previous_posts_link('Newer Entries &raquo;') ?>
          </div>
        </div>
        <?php else : ?>
        <h2 class="center">Not Found</h2>
        <p class="center">Sorry, but you are looking for something that isn't here.</p>
        <?php include (TEMPLATEPATH . "/searchform.php"); ?>
        <?php endif; ?>

    the previous_posts_link shows up but just displays the same posts as on the home page.

  2. stepterr
    Member
    Posted 5 years ago #

    trb310,
    I'm trying to do the same thing and was wondering what you did to resolve your issue.

    Thanks in advance!

  3. stepterr
    Member
    Posted 5 years ago #

    Nevermind. :) I just found another solution that did the trick for me. In case anyone else runs into this thread check out this post. http://wordpress.org/support/topic/201076?replies=2

Topic Closed

This topic has been closed to new replies.

About this Topic