• Hello all,
    I have looked around the forums and seen some things that look like pagination for WP. However, I want to be sure and ask for something specifically and see what you peeps turn up.
    Problem:
    When the categories start to fill up with posts and someone clicks on the category I want it so that if there are more then 5 ( most likely ) that the screen will show 5 and at the bottom have a pagination area so that they can get to page 2, 3, 4 >> .. whatever.
    Is there something like this built into 1.2 or is this something I have to find a hack for? If so,, then please tell me which is the best hack availalbe to achieve this.
    Kind regards,
    gravity

Viewing 15 replies - 1 through 15 (of 31 total)
  • This has been accomplished generally speaking.
    the thread you want to read up on is actually called “vBulletin Style Page Navigation,” but i can’t seem to find it anymore either. That doesn’t mean it’s not here, it just means i am too stupid to successfully use a search feature (sorry.)
    so i’ll reproduce the essential contents here:
    /* WordPress 1.0 vBulletin Style Page Navigation
    *
    * Last Updated On 28th Marchy 2004
    * Based On WP 1.1 Beta
    *
    * Usage:
    * - Options > Other Options > Set what_to_show to Post Paged
    * - Copy the below function and paste it in my-hacks.php
    * - Edit your index.php file and place <?=page_navigation()?> to where you want it to be displayed.
    */
    function page_navigation($before='', $after='', $prelabel='« ', $nxtlabel=' »') {
    global $p, $what_to_show, $request, $posts_per_page, $wpdb;
    global $HTTP_SERVER_VARS, $paged;
    global $querystring_start, $querystring_equal, $querystring_separator;
    if (empty($p) && ($what_to_show == 'paged')) {
    $nxt_request = $request;
    $whichpage = $_GET['paged'];
    if(empty($whichpage)) $whichpage = 1;
    $qstr = $HTTP_SERVER_VARS['QUERY_STRING'];
    if (!empty($qstr)) {
    $qstr = preg_replace("/&paged=\d{0,}/","",$qstr);
    $qstr = preg_replace("/paged=\d{0,}/","",$qstr);
    } elseif (stristr($HTTP_SERVER_VARS['REQUEST_URI'], $HTTP_SERVER_VARS['SCRIPT_NAME'] )) {
    if ('' != $qstr = str_replace($HTTP_SERVER_VARS['SCRIPT_NAME'], '', $HTTP_SERVER_VARS['REQUEST_URI']) ) {
    $qstr = preg_replace("/^\//", "", $qstr);
    $qstr = preg_replace("/paged\/\d{0,}\//", "", $qstr);
    $qstr = preg_replace("/paged\/\d{0,}/", "", $qstr);
    $qstr = preg_replace("/\/$/", "", $qstr);
    }
    }
    if ($pos = strpos(strtoupper($request), 'LIMIT')) {
    $nxt_request = substr($request, 0, $pos);
    }
    $nxt_result = $wpdb->query($nxt_request);
    $numposts = $wpdb->num_rows;
    $max_page = ceil($numposts / $posts_per_page) ;
    echo $before.'Pages ('.$max_page.') : <b>';
    if ($whichpage >= 4)
    echo '« First ... ';
    previous_posts_link($prelabel);
    for($i = $whichpage - 2 ; $i <= $whichpage +2; $i++) {
    if ($i >= 1 && $i <= $max_page) {
    if($i == $whichpage)
    echo '['.$i.'] ';
    else
    echo ''.$i.' ';
    }
    }
    next_posts_link($nxtlabel, $max_page);
    if (($whichpage+2) < ($max_page))
    echo ' ... Last »';
    echo '</b>'.$after;
    }
    }

    Now what i don’t know how to accomplish is what you are suggesting:
    add this pagination when a Category is selected and there are more posts within it than the page minimum posts shown can display (after a while with a blog, this would most likely be all categories, right?)
    how to address that without also adding this to the index.php i don’t know, but would really like to know.
    anyone?
    dss

    Well what’dya know…
    here’s the permalink to the original topic:
    http://wordpress.org/support/10/1542
    enjoy!
    dss

    Thread Starter gravity

    (@gravity)

    Whoa…..
    Thanks for the information.. I have to get RingMaster to create a plugin for this. It is needed quite badly..
    Hey RingMaster if you are around.. any chance? Read above for specific requirements.. I am sure if this was a plugin it would be a life saver.
    Thanks again…
    Gravity

    Already done. A simple search:
    http://wordpress.org/support/10/9445

    Thread Starter gravity

    (@gravity)

    Well thank you both…
    One last question…
    Please Make Sure Post Paged Is Turned On?
    Where do you turn this on.. exactly..
    Kind regards,
    gravity

    Thread Starter gravity

    (@gravity)

    well..
    based on the other thread.. do I still have to modify those things in order to the the next tabs to function?
    Also, any one want to comment on how I make the font of the pagination be more like my site..
    a simple <?php endif; ?><il><? page_navigation(); ?></il></div> did not work…. Can someone please cut me a piece of added CSS..
    http://www.arklinux.info
    Kind regards,
    gravity.

    Thread Starter gravity

    (@gravity)

    ( sigh ) sorry for so many questions.
    Where is “prev_next_links”?
    the only thing I did was add the code to the index page that blurb above and activate the plugin.
    So I have no idea where that is.. sorry..
    Kind regards,
    gravity

    Thread Starter gravity

    (@gravity)

    ah crap.. I understand now..
    I missed the
    #prev_next_links {whatever you want}
    sorry

    Thread Starter gravity

    (@gravity)

    Hmmmmmm
    I added this:
    #prev_next_links {
    color: fff;
    font-family: verdana, tahoma, arial, helvetica, geneva,
    sans-serif, bitstream vera sans;
    font-size: 10px;
    }
    Not working.. did I do something wrong?
    Kind regard,
    gravity

    wow,
    see what happens when you follow a link and read up on error404.com’s blog?
    looks like you are in better hands than mine.
    glad you are sorted.
    dss.

    Thread Starter gravity

    (@gravity)

    ok..
    The reason it has the <il> tags is because that is what in the other thread the code was changed to in order to work:
    f you go to your site and you do not see the navigation at the bottom of your page, do this. In your index.php on the line that says
    <?php endif; ?> change it to look like this <?php endif; ?><il><? page_navigation(); ?></il></div> that should do it.
    So what I need is specifics.. I changed it to il and I have the code you gave…. but it is still wrong.. let me read above and see what else you are saying..

    Thread Starter gravity

    (@gravity)

    OK OK..
    so here is the scoop… What you do is:
    1. download the plugin
    2. upload plugin to /includes/plugins
    3. edit index.php and add change <?php endif; ?> to <?php endif; ?><? page_navigation(); ?></div>
    Done.
    Now if you want to make it so that the ? page_navigation uses a different css option and has some padding what do we change above?
    The reason I re write this is for ease for someone else. So if you are available.. lets continue. I want to have the page option to the right of the content, not on the left or if it has to stay on the left I want it indented 10px.
    Please advise.

    Thread Starter gravity

    (@gravity)

    not sure what happened, but #3 is suppose to say
    <?php endif; ?><? page_navigation(); ?>
    and 4 should be activate plugin. Not sure if the code will take here.

    Thread Starter gravity

    (@gravity)

    < p > <?php endif; ?><? page_navigation(); ?></ p >

    Thread Starter gravity

    (@gravity)

    @beel,
    Where is that code.. are you replacing what I have above with what you posted above?

Viewing 15 replies - 1 through 15 (of 31 total)
  • The topic ‘Pagination’ is closed to new replies.