WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Pagination problem (5 posts)

  1. Dviper87boog
    Member
    Posted 3 years ago #

    Hello,

    I'm making a page with a query_posts loop where I gather all the games (posts) of a certain category. I'm using the gd star rating plugin and thus order them accordingly to their rating. Furthermore, I use navipage, please don't mention the looks of it yet as I have not paid attention to them yet and looks horrible.

    This is the page:
    http://www.bestofonlinegames.com/strategy

    When I click on page 2 or 3, it still shows the resulsts from page 1. Page 2's URL shows as http://www.bestofonlinegames.com/strategy/page/2

    The code:

    ?php
    if ( have_posts() ) :
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts('gdsr_sort=rating&gdsr_order=desc&cat=99&paged=$paged&posts_per_page=3');
    while ( have_posts() ) : the_post();
    ?>

    ...loop...

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

    How can I solve this? tried various suggestions on what I could find when googling this problem. Thanks in advance!

  2. Dviper87boog
    Member
    Posted 3 years ago #

    Tried a few other things from other forums, still no luck. Anyone?

  3. esmi
    Forum Moderator
    Posted 3 years ago #

    Try:

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts('gdsr_sort=rating&gdsr_order=desc&cat=99&paged=' . $paged . '&posts_per_page=3');

  4. Dviper87boog
    Member
    Posted 3 years ago #

    SOLVED:

    Problem was my custom permalink structure, had to add a function to strip the /page/2

    function curPageURL() {
     $pageURL = 'http';
     //check what if its secure or not
     if ($_SERVER["HTTPS"] == "on") {
     $pageURL .= "s";
     }
     //add the protocol
     $pageURL .= "://";
     //check what port we are on
     if ($_SERVER["SERVER_PORT"] != "80") {
     $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
     } else {
     $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
     }
     //cut off everything on the URL except the last 3 characters
     $urlEnd = substr($pageURL, -3);
     //strip off the two forward shashes
     $page = str_replace("/", "", $urlEnd);
     //return just the number
     return $page;
     }
  5. Dviper87boog
    Member
    Posted 3 years ago #

    Oh your suggestion worked as well Esmi, was even easier! Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags