• Resolved anespa

    (@anespa)


    Dear friends,
    In my category news page I have done a pagination link. But it show more links than the actual content . So goto 404 page. How it can avoid . My code is

     <?php
    /**
     * The template for displaying the news category listing page
     *
     * @package WordPress
     * @subpackage Insight_Custom
     * @since Insight Custom 1.0
     */
    get_header(); 
    
    $dd = get_query_var('paged');
    //echo "page is ".$dd;
    $_GET['sa'] = ($dd == 0)?$_GET['sa']:0;
    //print_r($_GET);
    ?>
        <div class="spotlight"> <img src="<?php bloginfo('template_directory'); ?>/media/spotlight/spotlight-inner-01.jpg" alt="Inner spotlight" title="spotlight of inner page" border="0"  /> </div>
        <div class="content grid_12">
          <h2 style="color: #0b669b;">News Listing</h2>
          <div class="line"></div>
           <?php
           $categories = get_the_category();
           $cat = $categories[0]->term_id;
           $paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1;
           
           if($_GET['sa'] == 1){
             $ppp = -1;
           }else{
             $ppp = 4;
           }
           $args = array(
             'posts_per_page' => $ppp,
             'paged' => $paged,
             'cat' => $cat
           );
           query_posts($args);
           while (have_posts()) :
           the_post(); ?>
           <h3 style="color: #0b669b"><?php the_title(); ?></h3>
           <?php
            the_content();
           ?>
           
          <?php endwhile;
           ?>
          <div align="center">
          <?php
          
          $big = 999999999; // need an unlikely integer
          echo paginate_links( array(
       'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
       'format' => '?paged=%#%',
       'current' => max ( 1, get_query_var('paged') )
       //'total' => 2000
     ) );
          ?>
         <?php if($ppp == 2) { ?>
         <span style="padding-left: 14px;"> <a href="<?php echo home_url();?>/category/news/?sa=1" style="color:#3B5998">Show all</a> </span>
          <?php } else { ?>
          <span style="padding-left: 14px;"> <a href="<?php echo home_url();?>/category/news/" style="color:#3B5998">Show less</a> </span>
          <div class="col-md-12 back-to-top">
            <a href="#top"> <img src="<?php bloginfo('template_directory'); ?>/media/images/backtop.png" alt="Get to the top"></a>
            <p class="back-text">Get to the top</p>
          </div>
          <?php } ?>
    
          </div>
         
         </div>
    
     
        </div>
         <?php get_sidebar(); ?>
        <br  clear="all" />
      </div>
      <!-- End Container -->
    </div>
    <?php get_footer (); ?> 

    Please advise

    Waiting for fast reply

    Thanks
    Anes

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Why the Paagination show more links than content ?’ is closed to new replies.