• Hi,
    Im coming with a new issue!

    I have an index.php with 4 differents and a pagination.
    To have my pagination works i hade to find a way to not use the offset option.

    So there is my index.php:

    <?php GET_HEADER(); ?>
         <section class="first-news flex inner">
    <?php
    
    /**
     **
     ** The first loop that show the first 2 post
     **
     **
     */
    
    query_posts(array('ignore_sticky_posts' => 1, 'showposts' => 2));
    $ids = array();
    while (have_posts()) : the_post();
    $ids[] = get_the_ID();  ?>   
    
          <article class="flex-6">
            <a href="<?php the_permalink() ?>">
              <?php the_post_thumbnail( 'thumbnail_top2' ); ?>
              <div class="db-border"></div>
              <div class="overlay">
                <div class="overlay-inner">
                  <h2 class="white"><?php the_title(); ?></h2>
                  <div class="cat dessert">Dessert</div>
                </div>
              </div>
            </a>
          </article>
    <?php endwhile;  ?>  
    
    /**
     **
     ** The second loop that ignore the first 2 post and show the next 3 posts
     **
     **
     */
    
    <?php
    query_posts(array('ignore_sticky_posts' => 1, 'post__not_in' => $ids, 'showposts' => 3));
    while (have_posts()) : the_post();
    $ids[] = get_the_ID();
      ?>
          <article class="flex-4">
            <a href="<?php the_permalink() ?>">
              <?php the_post_thumbnail( 'thumbnail_nextTop3' ); ?>
              <div class="db-border"></div>
              <div class="overlay">
                <div class="overlay-inner">
                  <h2 class="white"><?php the_title(); ?></h2>
                  <div class="cat dessert">Dessert</div>
                </div>
              </div>
            </a>
          </article>
    <?php endwhile;?>     
    
        </section>
        <div class="separation" id="last-news"><h1>Il y a encore pleeeein de recette par ici!</h1></div>
    
        <div class="flex inner">
          <section class="flex-9 last-news">
            <div class="content flex">     
    
    /**
     **
     ** the third loop that display the 9next posts
     **
     **
     */
    
    <?php
      global $wp_query;
      $temp = $wp_query;
      $wp_query = new WP_Query();
      $wp_query->query('posts_per_page=9'.'&paged='.$paged);
      query_posts(array('ignore_sticky_posts' => 1, 'post__not_in' => $ids,'showposts' => 9, 'paged' => $paged));
          while (have_posts()) : the_post(); ?>       
    
            <article class="flex-4">
             <a href="<?php the_permalink() ?>">
                <?php the_post_thumbnail( 'thumbnail_nextTop3' ); ?>
                <div class="comment"><span class="number"><?php comments_number('0','1','%'); ?></span><i class="fa fa-comment"></i></div>
                <div class="desc">
                  <div class="cat boisson">boisson</div>
                  <h2><?php the_title(); ?></h2>
                  <p><?php the_excerpt(); ?></p>
                </div>
              </a>
            </article>
           <?php endwhile; ?>
    
    /**
     **
     ** there is my pagination
     **
     **
     */
    
      <?php
        pressPagination($pages ='', $range = 2) ;
        $wp_query = null;
        $wp_query = $temp;
      ?>
            </div>
          </section>
    
    <?php GET_SIDEBAR(); ?>
    
          </div>
          <section class="pop inner">
            <h5>Les articles les plus populaires</h5>
            <div class="flex">
    /**
     **
     ** And there is a fourth loop to display the most valuable posts according to the number of their comments
     **
     **
     */
    
    <?php query_posts(	array('ignore_sticky_posts' => 1, 'posts_per_page' => 4, 'orderby' => 'comment_count', 'order' => 'DESC')); ?>
    	<?php while (have_posts()) : the_post(); ?>
    	          <article class="flex-6 flex align-center">
                <div class="flex-4"><a href="<?php the_permalink() ?>"><?php the_post_thumbnail( 'thumbnail_pop' ); ?></a></div>
                <div class="flex-8">
                  <h2><?php the_title(); ?></h2>
                  <?php the_advanced_excerpt('length=40&length_type=words&no_custom=1&ellipsis=%26hellip;'); ?>
                  <footer class="ovh flex align-center">
                    <div class="left comment flex-6"><a href="#"><?php comments_number('0','% commentaire','% commentaires'); ?></a></div>
                    <div class="flex-6"><a href="<?php the_permalink() ?>" class="btn right" >Lire l'article</a></div>
                  </footer>
                </div>
              </article>
    	<?php endwhile;?>
            </div>      
    
          </section>
    <?php GET_FOOTER(); ?>

    There is the code in functions.php for the pagination

    // Pagination
    function pressPagination($pages = '', $range = 2)
    {
        global $paged;
        $showitems= ($range * 2)+1;
    
        if(empty($paged)) $paged = 1;
        if($pages == '')
        {
            global $wp_query;
            $pages = $wp_query->max_num_pages;
            if(!$pages)
            {
                       $pages = 1;
            }
        }
    
        if(1 != $pages)
        {
            echo "<ul class='pagination flex-12 center inline inner' data-load='pagination'>";
            if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<li><a href='".get_pagenum_link(1)."'>«</a></li>";
            if($paged > 1 && $showitems < $pages) echo "<li><a href='".get_pagenum_link($paged - 1)."'>‹</a></li>";
    
            for ($i=1; $i <= $pages; $i++)
            {
                if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
                {
                    echo ($paged == $i)? "<li><span class='current'>".$i."</span></li>":"<li><a href='".get_pagenum_link($i)."' class='inactive' >".$i."</a></li>";
                }
            }
    
            if ($paged < $pages && $showitems < $pages) echo "<li><a href='".get_pagenum_link($paged + 1)."'>›</a></li>";
               if ($paged < $pages-1 &&  $paged+$range-1 < $pages && $showitems < $pages) echo "<li><a href='".get_pagenum_link($pages)."'>»</a></li>";
               echo "</ul>";
           }
    
    }

    Everything is working fine this way BUT when i create my 404.php file, the last 3 pages of my pagination goes this way! But if i don’t have any 404.php file, the last 3 pages works fine!

    what can goes wrong? 🙁

    Thanks for your time

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter malus

    (@malus)

    I don’t know what i can do to test anything.. This works fine when i don’t have the template page 404.php …

    Thread Starter malus

    (@malus)

    Any idea? 🙁

    Thread Starter malus

    (@malus)

    Nobody can help? 🙂

    Thread Starter malus

    (@malus)

    I would really appreciate some help!

    – I tryed to remove my pagination function and access manually to the last page but still get the error
    – I removed each loop from my index.php but one, still get the error;
    – I changed the last loop left to a standard one with wp_query, still get the error;
    – My module-rewite is correctly enable and nothing change when i change my permalink (i mean i still get the error in any cases);

    I don’t really know what i can do to test this kind of stuff..

    Im desperate 🙁

    The pagination works on the global before your template page even loads. This happens when the global query thinks that there are not more than one page.

    Thread Starter malus

    (@malus)

    Ok so how can i force the global to load after my template ?

    Thread Starter malus

    (@malus)

    How can i make this works then?
    Is there another way to set a pagination without global?

    This is really important :s

    Thread Starter malus

    (@malus)

    Still not solved!

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Pagination calling 404.php’ is closed to new replies.