• Hi,

    I have my site https://freecoupon.co.in on wordpress 3.1.3. I had moved that site to another domain https://couponhut.in and upgraded the wp version with 3.5.1 . Now I am facing pagination problem on home page as when I clicked on page 2 it shows the url https://couponhut.in/?paged=2 and throws 404 error. When I changed url https://couponhut.in/?paged=1 manually, it works. Pagination works normally on inner pages like https://couponhut.in/?stores=zoomin&paged=2 . If I change my home url https://couponhut.in/?post_type=coupon&paged=2 again it works.

    My Index.php :

    <?php get_header(); ?>
    <div id="content">	
    
    	<?php if(file_exists(STYLESHEETPATH . '/featured.php')) include_once(STYLESHEETPATH . '/featured.php'); else include_once(TEMPLATEPATH . '/featured.php'); ?>
    
        <div class="content-box">
    
            <div class="box-t">?</div>
    
            <div class="box-c">
    
                <div class="box-holder">
    
                    <div class="head">
    
                        <h2><?php _e('New Coupons', 'appthemes'); ?></h2>
    
    					<div class="counter"><?php printf(__('There are currently %s active coupons', 'appthemes'), '<span>'. appthemes_count_posts(APP_POST_TYPE, 'publish') . '</span>'); ?></div>
    
                    </div> <!-- #head -->
    
                    <?php
                    // show all coupons and setup pagination
                    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
                    query_posts(array('post_type' => APP_POST_TYPE, 'caller_get_posts' => 1, 'paged' => $paged));
                    ?>
    
                    <?php get_template_part('loop', 'coupon'); ?>
    
                </div> <!-- #box-holder -->
    
            </div> <!-- #box-c -->
    
            <div class="box-b">?</div>
    
        </div> <!-- #content-box -->
    
    </div><!-- #container -->
    
    <?php get_sidebar('home'); ?>
    
    <?php get_footer(); ?>
    
    And I used non plugin version of WP-pageNavi (2.5) in theme function like:
    
    // slimmed down non-plugin version of WP-PageNavi (2.50) by Lester 'GaMerZ' Chan https://lesterchan.net
    function appthemes_pagination($before = '', $after = '') {
        global $wpdb, $wp_query;
    
        if (!is_single()) :
    
            $pagenavi_options = array(
                    'pages_text' => __('Page %CURRENT_PAGE% of %TOTAL_PAGES%','appthemes'),
                    'current_text' => '%PAGE_NUMBER%',
                    'page_text' => '%PAGE_NUMBER%',
                    'first_text' => __('?? First','appthemes'),
                    'last_text' => __('Last ??','appthemes'),
                    'next_text' => '??',
                    'prev_text' => '??',
                    'dotright_text' => '',
                    'dotleft_text' => '',
                    'style' => 1,
                    'num_pages' => 15,
                    'always_show' => 0,
                    'num_larger_page_numbers' => 3,
                    'larger_page_numbers_multiple' => 30,
            );
    
            $posts_per_page = intval(get_query_var('posts_per_page'));
            $paged = intval(get_query_var('paged'));
            $numposts = $wp_query->found_posts;
            $max_page = $wp_query->max_num_pages;
    
            if(empty($paged) || $paged == 0) $paged = 1;
    
            $pages_to_show = intval($pagenavi_options['num_pages']);
            $larger_page_to_show = intval($pagenavi_options['num_larger_page_numbers']);
            $larger_page_multiple = intval($pagenavi_options['larger_page_numbers_multiple']);
            $pages_to_show_minus_1 = $pages_to_show - 1;
            $half_page_start = floor($pages_to_show_minus_1/2);
            $half_page_end = ceil($pages_to_show_minus_1/2);
            $start_page = $paged - $half_page_start;
    
            if($start_page <= 0) $start_page = 1;
    
            $end_page = $paged + $half_page_end;
    
            if(($end_page - $start_page) != $pages_to_show_minus_1) $end_page = $start_page + $pages_to_show_minus_1;
    
            if($end_page > $max_page) {
                $start_page = $max_page - $pages_to_show_minus_1;
                $end_page = $max_page;
            }
    
            if($start_page <= 0) $start_page = 1;
    
            $larger_per_page = $larger_page_to_show*$larger_page_multiple;
            $larger_start_page_start = (appthemes_round($start_page, 10) + $larger_page_multiple) - $larger_per_page;
            $larger_start_page_end = appthemes_round($start_page, 10) + $larger_page_multiple;
            $larger_end_page_start = appthemes_round($end_page, 10) + $larger_page_multiple;
            $larger_end_page_end = appthemes_round($end_page, 10) + ($larger_per_page);
    
            if($larger_start_page_end - $larger_page_multiple == $start_page) {
                $larger_start_page_start = $larger_start_page_start - $larger_page_multiple;
                $larger_start_page_end = $larger_start_page_end - $larger_page_multiple;
            }
    
            if($larger_start_page_start <= 0) $larger_start_page_start = $larger_page_multiple;
            if($larger_start_page_end > $max_page) $larger_start_page_end = $max_page;
            if($larger_end_page_end > $max_page) $larger_end_page_end = $max_page;
    
            if($max_page > 1 || intval($pagenavi_options['always_show']) == 1) :
                $pages_text = str_replace("%CURRENT_PAGE%", number_format_i18n($paged), $pagenavi_options['pages_text']);
                $pages_text = str_replace("%TOTAL_PAGES%", number_format_i18n($max_page), $pages_text);
    
                echo $before.'<div class="paging">'."\n";
    
    			if(!empty($pages_text)) echo '<div class="pages"><span class="total">'.$pages_text.'</span>';
    
    			if ($start_page >= 2 && $pages_to_show < $max_page) :
    				$first_page_text = str_replace("%TOTAL_PAGES%", number_format_i18n($max_page), $pagenavi_options['first_text']);
    				echo '<a href="'.esc_url(get_pagenum_link()).'" title="'.$first_page_text.'">'.$first_page_text.'</a>';
    
    				if(!empty($pagenavi_options['dotleft_text']))
    					echo '<span class="extend">'.$pagenavi_options['dotleft_text'].'</span>';
    			endif;
    
    			if($larger_page_to_show > 0 && $larger_start_page_start > 0 && $larger_start_page_end <= $max_page) :
    				for($i = $larger_start_page_start; $i < $larger_start_page_end; $i+=$larger_page_multiple) {
    					$page_text = str_replace("%PAGE_NUMBER%", number_format_i18n($i), $pagenavi_options['page_text']);
    					echo '<a href="'.esc_url(get_pagenum_link($i)).'" title="'.$page_text.'">'.$page_text.'</a>';
    				}
    			endif;
    
    			echo '<span class="prevPage">';
    			// give us the previous post link
    			previous_posts_link($pagenavi_options['prev_text']);
    			echo '</span>';
    
    			for($i = $start_page; $i  <= $end_page; $i++) :
    				if($i == $paged) {
    					$current_page_text = str_replace("%PAGE_NUMBER%", number_format_i18n($i), $pagenavi_options['current_text']);
    					echo '<span class="current">'.$current_page_text.'</span>';
    				} else {
    					$page_text = str_replace("%PAGE_NUMBER%", number_format_i18n($i), $pagenavi_options['page_text']);
    					echo '<a href="'.esc_url(get_pagenum_link($i)).'" title="'.$page_text.'">'.$page_text.'</a>';
    				}
    			endfor;
    
    			echo '<span class="nextPage">';
    			// give us the next post link
    			next_posts_link($pagenavi_options['next_text'], $max_page);
    			echo '</span>';
    
    			if($larger_page_to_show > 0 && $larger_end_page_start < $max_page) :
    				for($i = $larger_end_page_start; $i <= $larger_end_page_end; $i+=$larger_page_multiple) {
    					$page_text = str_replace("%PAGE_NUMBER%", number_format_i18n($i), $pagenavi_options['page_text']);
    					echo '<a href="'.esc_url(get_pagenum_link($i)).'" title="'.$page_text.'">'.$page_text.'</a>';
    				}
    			endif;
    
    			if ($end_page < $max_page) :
    				if(!empty($pagenavi_options['dotright_text']))
    					echo '<span class="extend">'.$pagenavi_options['dotright_text'].'</span>';
    
    				$last_page_text = str_replace("%TOTAL_PAGES%", number_format_i18n($max_page), $pagenavi_options['last_text']);
    				echo '<a href="'.esc_url(get_pagenum_link($max_page)).'" title="'.$last_page_text.'">'.$last_page_text.'</a>';
    			endif;
    
                echo '</div><div class="clr"></div></div>'.$after."\n";
    
            endif;
    
        endif;
    }

    [Please post code or markup between backticks or use the code button. Or better still – use a pastebin. Your posted code may now have been permanently damaged/corrupted by the forum’s parser.]

    Please help me out on the issue.

Viewing 10 replies - 16 through 25 (of 25 total)
Viewing 10 replies - 16 through 25 (of 25 total)
  • The topic ‘pagination not working on home page’ is closed to new replies.