Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jan 19th, 2012  |  syntax: None  |  size: 1.12 KB  |  hits: 31  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. // Custom Next/Previous Page
  2. add_filter('wp_link_pages_args', 'wp_link_pages_args_prevnext_add');
  3. /**
  4.  * Add prev and next links to a numbered link list
  5.  */
  6. function wp_link_pages_args_prevnext_add($args)
  7. {
  8.     global $page, $numpages, $more, $pagenow;
  9.  
  10.     if (!$args['next_or_number'] == 'next_and_number')
  11.         return $args; # exit early
  12.  
  13.     $args['next_or_number'] = 'number'; # keep numbering for the main part
  14.     if (!$more)
  15.         return $args; # exit early
  16.  
  17. if($page == $pagenow) { // check if current link is current page
  18.     $args['pagelink'] = '<a href="#wrap">%</a>'; // assuming top div has ID "header"
  19.     } else {
  20.     $args['pagelink'] = '%';
  21.     }
  22.  
  23.     if($page-1) # there is a previous page
  24.         $args['before'] .= _wp_link_page($page-1)
  25.             . $args['link_before']. $args['previouspagelink'] . $args['link_after'] . '</a>'
  26.         ;
  27.  
  28.     if ($page<$numpages) # there is a next page
  29.         $args['after'] = _wp_link_page($page+1)
  30.             . $args['link_before'] . $args['nextpagelink'] . $args['link_after'] . '</a>'
  31.             . $args['after']
  32.         ;
  33.  
  34.     return $args;
  35. }