Site logo

Archived topic

Jump to page, input pagination

3 replies · Started by Kelly on February 4, 2022

Viewing posts 1–4 of 4

Switched to the GP from MH. I was using this code for the page navi, allows user to input the page number in an input box to quickly jump to that page. I thought the generate_paging_navigation hook was the one I needed to use but it's not working. What should I use?

if (!function_exists('generate_paging_navigation')) {
	function generate_paging_navigation() {
		global $wp_query;
	    $big = 9999;
	    $paginate_links = paginate_links(array(
	    	'base' 		=> str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
	    	'format' 	=> '?paged=%#%',
	    	'current' 	=> max(1, get_query_var('paged')),
	    	'prev_next' => true,
	    	'prev_text' => __('«', 'mh'),
	    	'next_text' => __('»', 'mh'),
	    	'total' 	=> $wp_query->max_num_pages)
	    );
		if ($paginate_links) {
	    	echo '<div class="loop-pagination clearfix">';
				echo $paginate_links;
			echo '<div class="ohd-page-skip" style="display:inline-block; margin-left:10px;">';
			echo '<form name="skip_pages" id="skip_pages" class="ohd-nav-form" action="'.$_SERVER['REQUEST_URI'].'" method="post">
			<label for="sortby" class="ohd-label ohd-hidden">'.__('Or skip to page', 'ohd_child').'</label>';
			echo '<input class="ohd-input-number" type="text" size="6" name="paged" value="'.max(1, get_query_var('paged')).'" style="width:30px;" /><input type="hidden" name="quick_jump" value="1" />
			<input class="ohd-button" value="Go" type="submit" > 
		</form>';
			echo '</div>';
			echo '</div>';
		}
	}
}

Hi there,

You may need to do something like this:

add_action( 'generate_paging_navigation', function() {
    // Your code in here.
} );

Let me know if that helps or not :)

Yes! Thank you!!!

You're welcome :)

This archived topic is closed to new replies.