Support » Fixing WordPress » WordPress pagination doesn't works

  • Hello, I have a problem with pagination on search results. If i want to go in page 2,3, etc.. I’m redirecting to homepage.

    I tried many methods to solve the problem but i did not found none..

    <?php
    /**
     * The template for displaying Search Results pages.
     *
     */
    
    get_header(); ?>
        <?php
            $search = isset( $_GET['s'] ) ? $_GET['s']: null;
            $user_filtre = '';
            $user_display = '';
    
            if( $search ){
                $user_filtre .= 's=' . $_GET['s'] . '&';
                $user_display .= 's=' . $_GET['s'] . '&';
            }
        ?>
    	<?php include_once( TEMPLATEPATH . '/_includes/search-template.php' ); ?>
    	<?php if(have_posts() ): ?>
    	<div class="browse-content">
    		<div class="container">
    			<h2 class="movies-found"><?php echo get_number_of_movies(); ?> Posts Found</h2>
    			<?php theme_pagination(); ?>
    			<section>
    				<div class="row">
    					<ul>
    					 <?php while ( have_posts() ) : the_post(); ?>
    							<?php  include '_includes/items/item_4.php';?>
    						<?php endwhile; ?>
    					</ul>
    				</div>
    			</section>
    			<?php theme_pagination(); ?>
    			</div>
    		</div>
    	</div>
    	 <?php endif; ?>
    
    <?php get_footer(); ?>

    This is the search.php

Viewing 7 replies - 1 through 7 (of 7 total)
  • Howdy @tcrmovies,

    theme_pagination() is not a WordPress core function. I am assuming it is a custom function defined in your theme. Is this a commercial theme or is it available on the repository here? You may have better luck requesting support from the theme developer(s). At the very least, it would be helpful if you could show the code for the function you are calling since it seems that is the source of your issue.

    I made the theme but, the pagination works on 2 websites, also on localhost, only on one website doesn’t works..

    WordPress need advance configuration on servers? or server block some function for which determine this problem?

    Moderator t-p

    (@t-p)

    Volunteer Moderator

    I made the theme

    – These forums are for free themes available in the WordPress theme directory at wordpress.org/themes/. Forum volunteers are not given access to commercial/custom products, so they would not know why your /custom/commercial theme or plugin is not working properly. The developers/vendors are responsible for supporting their custom/commercial product. See http://codex.wordpress.org/Forum_Welcome#Commercial_Products

    Since theme_pagination() is a custom function and only you know what it does, you should probably have showed that code instead of the search template.

    the pagination works on 2 websites, also on localhost, only on one website doesn’t works..

    Have you tried deactivating all of your plugins and reactivating one by one to check if the issue is plugin-related? If you are using that same function on other sites with no issue, it sounds like it could be a conflict with something that only the problem site is using. Without seeing the actual code to your custom function, I can only guess but I do not see how it could be server-related.

    this is the function

    function theme_pagination($pages = '', $range = 4){
         $showitems = ($range * 2)+1;
         global $paged;
         if(empty($paged)) $paged = 1;
         if($pages == '')
         {
             global $wp_query;
             $pages = $wp_query->max_num_pages;
             if(!$pages)
             {
                 $pages = 1;
             }
         }   
    
         if(1 != $pages)
         {
    
             echo "<div class=\"hidden-sm hidden-xs\"><ul class=\"tsc_pagination tsc_paginationA tsc_paginationA06\"><li><a class=\"hidden\" href=\"\">«</a></li>";
    		 echo "<li class=\"pagination-bordered\"><span>Page ".$paged." of ".$pages."</li>";
             if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<li><a href='".get_pagenum_link(1)."'>« First</a></li>";
             if($paged > 1 && $showitems < $pages) echo "<li><a href='".get_pagenum_link($paged - 1)."'>« Previous</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><a class=\"current\">".$i."</a></li>":"<li><a href='".get_pagenum_link($i)."' >".$i."</a></li>";
                 }
            }
    
            if ($paged < $pages && $showitems < $pages) echo "<li><a href=\"".get_pagenum_link($paged + 1)."\">Next »</a></li>";
            if ($paged < $pages-1 &&  $paged+$range-1 < $pages && $showitems < $pages) echo "<li><a href='".get_pagenum_link($pages)."'>Last »</a></li>";
            echo "</ul></div>\n";
    		 /* responsive */
    		echo "<div class=\"hidden-md hidden-lg\"><ul class=\"tsc_pagination tsc_paginationA tsc_paginationA06\">";
    		echo "<li><a href='".get_pagenum_link($paged - 1)."'>« Previous</a></li>";
    		echo "<li class=\"pagination-bordered\">".$paged." of ".$pages."</li>";
             echo "<li><a href=\"".get_pagenum_link($paged + 1)."\">Next »</a></li>";
             echo "</ul></div>\n";
         }
    }

    I deactivating all plugins, and reactivating one by one.. but same.

    That code works fine on my sandbox. Are you seeing anything in your server error logs related to this? Outside of that, as @tara said, we are very limited in support we can provide here when the issue is related to your custom theme that we don’t have access to.

    I don’t see nothing .. 🙁

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.