1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

wp-pagenavi not working

Discussion in 'Blogging' started by CardinalPPC, Sep 1, 2010.

  1. CardinalPPC

    CardinalPPC Newbie

    Joined:
    Jul 23, 2009
    Messages:
    35
    Likes Received:
    0
    I'm creating an arcade site using the WPArcade script and I'm almost done. The only issue right now is that the pagenavi plugin is showing white rectangles where the numbers should be. I've gone throughout the plugin, deleted and reinstalled it, and I still can't get it to work. Any suggestions?
     
  2. max2max

    max2max Newbie

    Joined:
    May 7, 2010
    Messages:
    6
    Likes Received:
    0
    Hey, you. Here is the solution. It's working without plugin, very good for you.

    1. Paste this code into functions.php or custom-functions.php
    PHP:
    <?php
    #Page Navi

    function page_navi($before ''$after '') {
        global 
    $wpdb$wp_query;
        
        
    $request $wp_query->request;
        
    $posts_per_page intval(get_query_var('posts_per_page'));
        
    $paged intval(get_query_var('paged'));
        
    $numposts $wp_query->found_posts;
        
    $max_page $wp_query->max_num_pages;
        
        if(empty(
    $paged) || $paged == 0) {
            
    $paged 1;
        }
        
    $pages_to_show 5;
        
    $pages_to_show_minus_1 $pages_to_show-1;
        
    $half_page_start floor($pages_to_show_minus_1/2);
        
    $half_page_end ceil($pages_to_show_minus_1/2);
        
    $start_page $paged $half_page_start;
        if(
    $start_page <= 0) {
            
    $start_page 1;
        }
        
    $end_page $paged $half_page_end;
        if((
    $end_page $start_page) != $pages_to_show_minus_1) {
            
    $end_page $start_page $pages_to_show_minus_1;
        }
        if(
    $end_page $max_page) {
            
    $start_page $max_page $pages_to_show_minus_1;
            
    $end_page $max_page;
        }
        if(
    $start_page <= 0) {
            
    $start_page 1;
        }
        
        echo 
    $before.'<center><div class="page_navi">'."\n";
        if (
    $start_page >= && $pages_to_show $max_page) {
            
    $first_page_text "First";
            echo 
    '<a href="'.get_pagenum_link().'" title="'.$first_page_text.'">'.$first_page_text.'</a>';
        }
        
    previous_posts_link('«');
        for(
    $i $start_page$i  <= $end_page$i++) {                        
            if(
    $i == $paged) {
                echo 
    '<span class="current">'.$i.'</span>';
            } else {
                echo 
    '<a href="'.get_pagenum_link($i).'">'.$i.'</a>';
            }
        }
        
    next_posts_link('»');
        if (
    $end_page $max_page) {
            
    $last_page_text "Last";
            echo 
    '<a href="'.get_pagenum_link($max_page).'" title="'.$last_page_text.'">'.$last_page_text.'</a>';
        }
        echo 
    '</div></center>'.$after."\n";
    }
    ?>
    2. Call page navi in theme file, for example: index.php, archive.php...
    PHP:
      <div class="page_navi">
        <?php page_navi(); ?>
      </div>
    3. Style for page navi, copy & paste this code into style.css, you can edit :p

    Good luck! :p