Forums

[resolved] WP-Paginate - span 'current' fixed on first li item regardless of page I'm on. (5 posts)

  1. surfsup74
    Member
    Posted 1 year ago #

    I have installed WP-Paginate and it's working except the first li item always has span="current" applied regardless of the page I'm viewing. So for example I have 3 pages, i click to go to page 3, I am taken to page 3 however the pagination does not update to refelt this (the first li item is still not linked and has span="current" around it. I have had exactly the same happen when i tried WP-Pagenavi so I must be doing someting slightly wrong. My loop below:

    <?php query_posts('category_name=events&orderby=rand&posts_per_page=10');?>
    <?php if(function_exists('wp_paginate')) {
    wp_paginate();
    } ?>

    <?php while (have_posts()) : the_post(); ?>
    <h4>" href="<?php the_permalink() ?>"><?php the_title(); ?></h4>
    <?php the_excerpt(); ?>
    <?php endwhile; ?>

    Any ideas anyone?

  2. surfsup74
    Member
    Posted 1 year ago #

    I've just taken the orderby=rand bit out and can now see that every page the pagination takes me to shows just the first set of 10 posts. If i have 50 posts the pagination creates 5 li items however every page shows the most recent 10?? (ie if I click number 2,3,4 or 5 I still see the most recent 10 - which I would expect to only see if I click number 1.

  3. Eric Martin
    Member
    Posted 1 year ago #

    You aren't including the paged parameter in your query_posts() function, so you will always see the first 10.

    See: http://wordpress.org/support/topic/plugin-wp-paginate-unable-to-get-page-number-and-advance-1?replies=3#post-1920380

  4. surfsup74
    Member
    Posted 1 year ago #

    Wow - quick response - much appreciated...

    So where in the example code I included do I put the example you directed me to please(below)? Also, in the example below what would YOUR-PARAMETERS be?

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("YOUR-PARAMETERS&paged=$paged");

  5. surfsup74
    Member
    Posted 1 year ago #

    Sorted it - thanks for your help.

    Does this look right? (it works)

    <?php query_posts('category_name=events&posts_per_page=10&paged='.$paged); ?>
    <?php if(function_exists('wp_paginate')) {
    wp_paginate();
    } ?>
    <?php while (have_posts()) : the_post(); ?>
    <h4>" href="<?php the_permalink() ?>"><?php the_title(); ?></h4>
    <?php the_excerpt(); ?>
    <?php endwhile; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic