topical media & game development

talk show tell print

professional-search-16-Digg-Plugins-pagerfix.php / php



  <?php 
  /* 
  Plugin Name: PagerFix 
  Plugin URI: http://www.seoegghead.com/ 
  Description: Makes the paging in WP more SE-friendly. 
  Author: Jaimie Sirovich 
  Version: 1.0 
  Author URI: http://www.seoegghead.com/ 
  */  
  function pager_fix(seperator = ' | ', 
                     after_previous = '&nbsp;&nbsp;', 
                     before_next = '&nbsp;&nbsp;', 
                     prelabel='&laquo; Previous Page', 
                     nxtlabel='Next Page &raquo;', 
                     current_page_tag = 'b') 
  {     
    global request, posts_per_page, wpdb, paged; 
       
    posts_nav_link('',prelabel,''); 
    echo after_previous; 
    preg_match('#FROM (.*) GROUP BY#', request, matches); 
    fromwhere = matches[1]; 
    numposts = wpdb->get_var("SELECT COUNT(ID) FROM fromwhere"); 
    max_num_pages = ceil(numposts / posts_per_page); 
    if (max_num_pages > 1) 
    { 
      for (cnt = 1; cnt <= max_num_pages; cnt++) 
      { 
        if (current_page_tag && paged == cnt) 
        { 
          begin_link = "<current_page_tag>"; end_link = "</current_page_tag>"; 
        } 
        else 
        { 
          begin_link = ''; end_link = ''; 
        } 
             
        x[] = begin_link . 
               '<a href="' . get_pagenum_link(cnt) . '">' . 
               cnt . '</a>' . end_link; 
        } 
     
        echo join(seperator, x); 
         
    } 
    echo before_next; 
    posts_nav_link('','',nxtlabel); 
     
  } 
  ?>


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.