Article Pagination
-
I need an article pagination button showing the number of pages and a Previous and Next button to navigate.
Could anyone tell me if the code below would solve my problem?
Which PHP file should I add the code?add_filter('wp_link_pages_args', 'wp_link_pages_args_prevnext_add'); function wp_link_pages_args_prevnext_add($args) { global $page, $numpages, $more, $pagenow; if (!$args['next_or_number'] == 'next_and_number') return $args; # exit early $args['next_or_number'] = 'number'; # keep numbering for the main part if (!$more) return $args; # exit early if($page-1) # there is a previous page $args['before'] .= _wp_link_page($page-1) . $args['link_before']. $args['previouspagelink'] . $args['link_after'] . '' ; if ($page<$numpages) # there is a next page $args['after'] = _wp_link_page($page+1) . $args['link_before'] . $args['nextpagelink'] . $args['link_after'] . '' . $args['after'] ; return $args; } function wp_link_pages( $args = '' ) { $defaults = (array( 'before' => '<p>' . __('Pages:'), 'after' => '</p>', 'next_or_number' => 'next_and_number', # activate parameter overloading 'nextpagelink' => __('Next'), 'previouspagelink' => __('Previous'), 'pagelink' => '%', 'echo' => 1 ) );
- The topic ‘Article Pagination’ is closed to new replies.