Pagination links not working

Forums › Forums › Search & Filter Pro › Pagination links not working

Tagged: 

Viewing 10 posts – 1 through 10 (of 13 total)
  • Anonymous
    #49082

    Hi – when I do a search the archive results pagination will not work. I think it is using a Loop like recommended. Here is the search.php. Any help would be greatly appreciated.

    <?php
    /**
    * @package WordPress
    * @subpackage Highend
    */
    ?>

    <?php get_header(); ?>

    <div id=”main-content”>
    <div class=”container”>

    <?php
    $sidebar_layout = hb_options(‘hb_page_layout_sidebar’);
    $sidebar_name = hb_options(‘hb_choose_sidebar’);
    ?>

    <div class=”row <?php echo $sidebar_layout; ?> main-row”>

    <!– BEGIN .hb-main-content –>
    <?php if ( $sidebar_layout && $sidebar_layout != ‘fullwidth’ ) { ?>
    <div class=”col-9 hb-equal-col-height hb-main-content”>
    <?php } else { ?>
    <div class=”col-12 hb-main-content”>
    <?php } ?>

    <div class=”aligncenter refine-search-wrapper”>
    <h4 class=”title-class semi-bold”><?php _e(‘Here is what we found for you.’, ‘hbthemes’); ?></h4>
    </div>

    <div class=”hb-separator extra-space”><div class=”hb-fw-separator”></div></div>

    <?php
    if (have_posts()) :
    if ( get_query_var(‘paged’) ) {
    $paged = get_query_var(‘paged’);

    if ($paged > 1){
    $search_counter = ($paged-1) * get_option(‘posts_per_page’);
    } else {
    $search_counter = 0;
    }
    } elseif ( get_query_var(‘page’) ) {
    $paged = get_query_var(‘page’);
    if ($paged > 1){
    $search_counter = ($paged-1) * get_option(‘posts_per_page’);
    } else {
    $search_counter = 0;
    }
    } else {
    $paged = 1;
    $search_counter = 0;
    }

    while (have_posts()) : the_post();
    $search_counter++;

    $format = get_post_format( get_the_ID() );
    $icon_to_use = ‘hb-moon-file-3’;

    if ($format == ‘video’){
    $icon_to_use = ‘hb-moon-play-2’;
    } else if ($format == ‘status’ || $format == ‘standard’){
    $icon_to_use = ‘hb-moon-pencil’;
    } else if ($format == ‘gallery’ || $format == ‘image’){
    $icon_to_use = ‘hb-moon-image-3’;
    } else if ($format == ‘audio’){
    $icon_to_use = ‘hb-moon-music-2’;
    } else if ($format == ‘quote’){
    $icon_to_use = ‘hb-moon-quotes-right’;
    } else if ($format == ‘link’){
    $icon_to_use = ‘hb-moon-link-5’;
    }

    $thumb = get_post_thumbnail_id( get_the_ID() );
    //$full_thumb = wp_get_attachment_image_src( get_post_thumbnail_id ( get_the_ID() ), ‘original’) ;

    echo ‘<article class=”search-entry clearfix”>’;
    echo ‘<span class=”search-result-counter “>’. $search_counter .'</span>’;

    if ( $thumb ) {
    $image = hb_resize( $thumb, ”, 120, 120, true );

    echo ‘'. get_the_title() .'‘;
    } else {
    echo ‘<i class=”‘. $icon_to_use .’”></i>‘;
    }

    $echo_title = get_the_title();
    if ( $echo_title == “” ) $echo_title = __(‘No Title’ , ‘hbthemes’ );
    echo ‘<h4 class=”semi-bold”>‘.$echo_title.’</h4>’;
    echo ‘<div class=”minor-meta”>’. get_the_time(‘M j, Y’) .'</div>’;

    echo ‘<div class=”excerpt-wrap”>’;
    the_excerpt();
    echo ‘</div>’;

    echo ‘</article>’;

    endwhile;

    hb_pagination_standard();

    else : ?>
    <h4 class=”title-class semi-bold”><?php _e(‘No results found.’, ‘hbthemes’); ?></h4>
    <?php endif;
    ?>
    </div>
    <!– END .hb-main-content –>
    <?php if ( $sidebar_layout && $sidebar_layout != ‘fullwidth’ ) { ?>
    <!– BEGIN .hb-sidebar –>
    <div class=”col-3 hb-equal-col-height hb-sidebar”>
    <?php
    if ( $sidebar_name && function_exists(‘dynamic_sidebar’) )
    dynamic_sidebar($sidebar_name);
    ?>
    </div>
    <!– END .hb-sidebar –>
    <?php } ?>
    </div>
    </div>
    </div>

    <?php get_footer(); ?>

    Trevor
    #49086

    Can I see a live page with the search on?

    Anonymous
    #49088
    Trevor
    #49126

    What theme is this?

    Anonymous
    #49170

    HB Themes “High End”

    Trevor
    #49171

    This seems to be the function to perform pagination:

    hb_pagination_standard();

    It might need replacing with the pagination code that you might find in our example template (results.php) (in the templates folder of the plugin)?

    Anonymous
    #49295

    Thank you! I understand that I have to put this code:

    Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?><br />
    	
    	<div class="pagination">
    		
    		<div class="nav-previous"><?php next_posts_link( 'Older posts', $query->max_num_pages ); ?></div>
    		<div class="nav-next"><?php previous_posts_link( 'Newer posts' ); ?></div>
    		<?php
    			/* example code for using the wp_pagenavi plugin */
    			if (function_exists('wp_pagenavi'))
    			{
    				echo "<br />";
    				wp_pagenavi( array( 'query' => $query ) );
    			}
    		?>
    	</div>

    to replace hb_pagination_standard();

    but not sure where to put it because a simple replace doesn’t work and I don’t fully understand php. Please can you tell me how do I make it work in this code?

    <?php
    
    	if (have_posts()) :
    
    	if ( get_query_var('paged') ) {
    
    	$paged = get_query_var('paged');
    
    	if ($paged > 1){
    
    	$search_counter = ($paged-1) * get_option('posts_per_page');
    
    	} else {
    
    	$search_counter = 0;
    
    	}
    
    	} elseif ( get_query_var('page') ) {
    
    	$paged = get_query_var('page');
    
    	if ($paged > 1){
    
    	$search_counter = ($paged-1) * get_option('posts_per_page');
    
    	} else {
    
    	$search_counter = 0;
    
    	}
    
    	} else {
    
    	$paged = 1;
    
    	$search_counter = 0;
    
    	}
    
    	while (have_posts()) : the_post();
    
    	$search_counter++;
    
    $format = get_post_format( get_the_ID() );
    
    	$icon_to_use = 'hb-moon-file-3';
    
    	if ($format == 'video'){
    
    	$icon_to_use = 'hb-moon-play-2';
    
            } else if ($format == 'status' || $format == 'standard'){
    
    	$icon_to_use = 'hb-moon-pencil';
    
    	} else if ($format == 'gallery' || $format == 'image'){
    
    	$icon_to_use = 'hb-moon-image-3';
    
    	} else if ($format == 'audio'){
    
    	$icon_to_use = 'hb-moon-music-2';
    
    	} else if ($format == 'quote'){
    
            $icon_to_use = 'hb-moon-quotes-right';
    
    	} else if ($format == 'link'){
    
    	$icon_to_use = 'hb-moon-link-5';
    
    	}
    
    	$thumb = get_post_thumbnail_id( get_the_ID() ); 
    
    	//$full_thumb = wp_get_attachment_image_src( get_post_thumbnail_id ( get_the_ID() ), 'original') ;
    
    							
    
    	echo '<article class="search-entry clearfix">';
    
    	echo '<span class="search-result-counter ">'. $search_counter .'</span>';
    
    	if ( $thumb ) {
    
    	$image = hb_resize( $thumb, '', 120, 120, true );
    
    	echo '<a href="'.get_permalink().'" title="'.get_the_title().'" class="search-thumb"><img src="'.$image['url'].'" alt="'. get_the_title() .'" /></a>';
    
    	} else {
    
    	echo '<a href="'.get_permalink().'" title="'.get_the_title().'" class="search-thumb"><i class="'. $icon_to_use .'"></i></a>';
    
    	}
    
    						
    
    	$echo_title = get_the_title();
    if ( $echo_title == "" ) $echo_title = __('No Title' , 'hbthemes' );
    
    	echo '<h4 class="semi-bold"><a href="'.get_permalink().'" title="'.$echo_title.'">'.$echo_title.'</a></h4>';
    
    	echo '<div class="minor-meta">'. get_the_time('M j, Y') .'</div>';
    
    					
    
    	echo '<div class="excerpt-wrap">';
    
    	the_excerpt();
    
    	echo '</div>';
    
    						
    
    	echo '</article>';
    
    						
    
    	endwhile;
    
    	hb_pagination_standard();
    
    				
    
    	else : ?>
    
    	<h4 class="title-class semi-bold"><?php _e('No results found.', 'hbthemes'); ?></h4>
    
    	<?php endif;
    
    	?>
    
    

    THANK YOU FOR YOUR HELP!

    Trevor
    #49298

    Are you able to find that function within your theme so I can see that its code does?

    Anonymous
    #49381

    Found it! THANK YOU FOR YOUR HELP!!!!

    <?php
    /**
     * @package WordPress
     * @subpackage Notable
     */
    
    //pagination function
    if ( !function_exists('hb_pagination_standard') ) {
        function hb_pagination_standard($pages = '', $range = 4, $query = null) {
            global $wp_query;
            global $paged, $max_page;
    
            $big = 99999999;
            echo '<div class="clear"></div>';
            echo '<div class="pagination">';
            echo paginate_links(array(
                'base' => str_replace($big, '%#%', get_pagenum_link($big)),
                'format' => '?paged=%#%',
                'total' => $wp_query->max_num_pages,
                'current' => max(1, get_query_var('paged')),
                'show_all' => false,
                'end_size' => 2,
                'mid_size' => 1,
                'prev_next' => true,
                'prev_text' => '<i class="icon-angle-left"></i>',
                'next_text' => '<i class="icon-angle-right"></i>',
                'type' => 'list'
            ));
            echo '</div>';
            echo '<div class="clear"></div>';
        }
    }
    ?>
    Trevor
    #49388

    Got it working now? If yes, can I mark this as resolved and close the thread?

Viewing 10 posts – 1 through 10 (of 13 total)

Search & Filter Support
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

We also use cookies to store items in your cart as well as allowing your to login on the site.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.

By continuing to use this site, you also agree to our Privacy Policy.