Results 1 to 3 of 3

Thread: Page/Post Navigation just reloads the page

  1. #1
    arronjuk is offline Hello World
    Join Date
    Dec 2010
    Posts
    2

    Icon5 Page/Post Navigation just reloads the page

    Hi

    I have 2 blog pages within a mainly CMS wordpress site. I have a template file called news that both these blog pages use. The file looks at what page it is and retrieves the post within the relevant category (so 2 categories and 2 pages). I also have archives links at the top of the page, again filtered by categories. This all works fine.

    The problem is I wanted to only show the latest 5 posts (within the relevant category) and then have navigation at the bottom for the next 5 posts ect..

    When I click next page or previous entries, it just reloads the same page with the same posts. I did notice that the url gets /page/2 added though?!

    Below is what I have so far...

    Any help is hugely appreciated! ! !
    HTML Code:
    div id="content">
    <div id="archiveheader">
    <?php //Set the relevant category to the variable
    if ( is_page('world-heritage-latest') )$C=3;
    elseif ( is_page('great-lines-heritage-park-latest') ) $C=4;
    //Display archive years for the selected category, made possible by Kwebble Archives plugin.
    wp_get_archives('type=yearly&cat='.$C); ?>
    </div> 
    
    <?php //Display posts for relevant category
    query_posts('posts_per_page=5&cat='.$C);
    ?>
    
    <?php if (have_posts()) : ?>
    
    <?php while (have_posts()) : the_post(); ?>
    
    <div class="post" id="post-<?php the_ID(); ?>">
    <h1>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></h1>
    <?php the_date('', '<h2>', '</h2>'); ?>
    <div class="entry">
    <?php the_content('Read More »'); ?>
    </div>
    
    </div>
    
    <?php endwhile; ?>
    <div class="navigation">
    <div class="alignleft"><?php posts_nav_link('','','« Previous Entries') ?></div>
    <div class="alignright"><?php posts_nav_link('','Next Entries »','') ?></div>
    </div>
    <?php else : ?>

  2. #2
    chipbennett's Avatar
    chipbennett is offline WordPress Legend
    Join Date
    Feb 2009
    Location
    St. Louis, MO
    Posts
    1,997

    Default

    Quote Originally Posted by arronjuk View Post
    Hi

    I have 2 blog pages within a mainly CMS wordpress site. I have a template file called news that both these blog pages use. The file looks at what page it is and retrieves the post within the relevant category (so 2 categories and 2 pages). I also have archives links at the top of the page, again filtered by categories. This all works fine.

    The problem is I wanted to only show the latest 5 posts (within the relevant category) and then have navigation at the bottom for the next 5 posts ect..

    When I click next page or previous entries, it just reloads the same page with the same posts. I did notice that the url gets /page/2 added though?!

    Below is what I have so far...

    Any help is hugely appreciated! ! !
    If I had to guess, I'd say that it's due to the way you're handling your custom querying of posts. See the Codex for query_posts().

    One thing I notice immediately is that you don't begin your query_posts() argument with an ampersand. You also don't globalize $query_string, or pass it into the query_posts() argument.

    Also, you might want to use get_posts() instead of query_posts().
    WP TurnKey - Turn-Key WordPress installation and maintenance services
    WordPress user since 2005 | @chip_bennett | chipbennett.net | cbnet Plugins

  3. #3
    Otto's Avatar
    Otto is offline On The Rocks
    Join Date
    Apr 2009
    Location
    Memphis, TN
    Posts
    865

    Default

    Chip nailed it.
    PHP Code:
    query_posts($query_string.'&posts_per_page=5&cat='.$C); 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •