Forums › Forums › Search & Filter Pro › Pagination links not working
Tagged: pagination
- This topic has 12 replies, 3 voices, and was last updated 8 years, 5 months ago by Anonymous.
-
Anonymous(Private) June 21, 2016 at 6:32 pm #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 ‘‘;
} 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(); ?>
Anonymous(Private) June 21, 2016 at 7:32 pm #49088Thank you for your quick response. Here it is: http://solopreneurnetwork.com/?sfid=1662&_sft_category=management%2Cmarketing%2Cmoney%2Csales
Anonymous(Private) June 23, 2016 at 9:59 pm #49295Thank 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!
Anonymous(Private) June 24, 2016 at 4:26 pm #49381Found 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>'; } } ?>
-
AuthorPosts