Forums

Pagination (32 posts)

  1. gravity
    Member
    Posted 5 years ago #

    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

  2. dss
    Member
    Posted 5 years ago #

    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

  3. dss
    Member
    Posted 5 years ago #

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

  4. gravity
    Member
    Posted 5 years ago #

    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

  5. Beel
    Member
    Posted 5 years ago #

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

  6. gravity
    Member
    Posted 5 years ago #

    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

  7. gravity
    Member
    Posted 5 years ago #

    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.

  8. gravity
    Member
    Posted 5 years ago #

    ( 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

  9. gravity
    Member
    Posted 5 years ago #

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

  10. gravity
    Member
    Posted 5 years ago #

    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

  11. dss
    Member
    Posted 5 years ago #

    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.

  12. gravity
    Member
    Posted 5 years ago #

    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..

  13. gravity
    Member
    Posted 5 years ago #

    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.

  14. gravity
    Member
    Posted 5 years ago #

    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.

  15. gravity
    Member
    Posted 5 years ago #

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

  16. gravity
    Member
    Posted 5 years ago #

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

  17. Beel
    Member
    Posted 5 years ago #

    It is just after the end of the post loop and before the menu in the index file.

  18. gravity
    Member
    Posted 5 years ago #

    @everyone
    I did exactly what was above and it all works.. ;)
    in the index you add what @beel has above and in the wp-layout.css you add:
    #prev_next_links {
    color: #000000;
    font-family: verdana, tahoma, arial, helvetica, geneva, sans-serif, bitstream vera sans;
    font-size: 10px;
    }
    to the bottom. There you can make your pagination look and be anywhere you want.
    Thanks to everyone for this..

  19. gravity
    Member
    Posted 5 years ago #

    @beel
    any comments on this? is this something that still needs to be done?
    In order to get the $prelabel and $nxtlabel to work you will also have to fix line 40 and line 52.
    Replace: « First
    with '. $prelabel . 'First
    and replace: Last »
    with: Last ' . $nxtlabel . '
    Haven't figured out how to get nice urls yet.
    Kind regards,
    gravity

  20. gravity
    Member
    Posted 5 years ago #

    nope.. I do not want permalinks.. However, I am unfamiliar with the terms:
    laquo and raquo
    so this is where it gets rough.. I need more specifics on what to change. This next step looks like once again I have to change the code in the index and something in the plugin. Is this correct. If so
    lets start with the index first and then in your response write
    now in the plugin code change this:
    if you would be so kind.
    Kind regards
    redfrog
    also, since I am new to bloggin can you give a good description of what the permalink does. I assume it is a permanent link so that other places can link to that post? am I wrong?

  21. gravity
    Member
    Posted 5 years ago #

    also,
    I just noticed on your blog you do not have the numbers.. so is this change to get rid of number and just have next and previous tabs? If so then we do not have to get into it other then for others if you already started.. I am good with the numbers.
    These numbers... how high will they go until they become >> or something. what is the magic number? I certainly do not want page 1,2,3,4,5,6,7 up to 30 at the bottom of the page.
    Just need a little insight.

  22. dodo
    Member
    Posted 5 years ago #

    where is posted page option?? how i do turn it on?

  23. dodo
    Member
    Posted 5 years ago #

    n/m figured it out

  24. Beel
    Member
    Posted 5 years ago #

    I do not have the numbers because the plugin will not work in 1.3-alpha-2 (as in 2 days ago) and I have not tweaked it yet so that it will... there, now I have. What you saw was the WP 1.2 version of "Previous | Next"
    If you like what you have, don't mess with it anymore. If you would like to change the << and >>, you will have to tweak the plugin code (directions in other thread and as follows).
    As for the index page, it is done except for what you put between the () of page_navigation. If you look at the plugin, the function looks like this:
    page_navigation($before='', $after='', $prelabel='« ', $nxtlabel=' »')
    but the lines I mentioned in the other post echo a link which does not include $prelabel and $nxtlabel. It echoes the laquo and raquo (<< & >>) instead. Replace those with what I have in the post (don't forget the two periods and apostrophes.
    Once that is done, in the index file you can put page_navigation('before', 'after', 'prelabel', 'nxtlabel').
    You are on your own now as I have to get back to work.

  25. gravity
    Member
    Posted 5 years ago #

    Thanks..
    I will leave what I have alone.. I will just have to get back in touch with you guys as of 1.3 to make sure that no problems exist. Probably the worst thing in the world in upgrading especially when you have so many hacks included and are not sure if they work or not with the next version.
    Only time will tell.. For everyone else.. if all you are interested in is simple pagination.. look at the 1st page.. once you read the last few posts on page1 you will find it takes about 2 minutes to do.
    Thank for all your help in this Beel..

  26. gravity
    Member
    Posted 5 years ago #

    Hello all,
    Today after posting to the blog I checked Xhtml validation.. Now.. the thing is that the reason the validation is not working is cause of the pagination. I am pretty sure of this.
    Please check out the bottom of the blog:
    http://www.arklinux.info
    You will see that there is a '?' there instead of the '>>' However, I cannot see where I made a mistake. Xhtml validation says line 142 which I think is this line
    < ? php endif; ? >< p id="prev_next_links" >< ? page_navigation(); ? >< / p >
    Please tell me if something is wrong or what else I might check.. Hopefully someone can help me with that ASAP.. so I can change it accordingly.. Anyone Around ? :)
    Kind regards,
    gravity

  27. gravity
    Member
    Posted 5 years ago #

    Yeah.. I just cannot understand it.. ;) lol.. Its Malysian to me.. I will try again...
    Kind regards,
    Gravity

  28. Beel
    Member
    Posted 5 years ago #

    For now, just replace the characters with the code above and I'll help you fix the variables later -
    I'm late, I'm late
    For a very important date
    No time to say "Hello", "Goodbye"
    I'm late, I'm late, I'm late
    No, no, no, no
    No, no, no, I'm overdue
    I'm really stew
    No time to say "Goodbye", "Hello"
    I'm late, I'm late, I'm late

  29. gravity
    Member
    Posted 5 years ago #

    Ahhh.. I think I got it..
    So a person has to edit the plugin and replace the >> with » and « accordingly..
    Anything else that needs changing?
    Have a nice time at church.. Pray for me ;)

  30. Beel
    Member
    Posted 5 years ago #

    Nothing else needs to be changed, unless you want to be able to change $prelabel and $nxtlabel without editing the plugin. Though the plugin indicates you can change it in the function call itself. as it is now, only laquo and raquo can be used. Following my directions, however, will allow you to change it in the function call.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.