WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Pagination, Not sure what to do

[Resolved] Pagination, Not sure what to do

Viewing 15 replies - 1 through 15 (of 42 total)
  • esmi

    @esmi

    Forum Moderator

    Have you tried using posts_nav_link?

    Yes, exactly what I have been using. As you can see, I got it to work for the “IF POST IS IN A CATEGORY” section. but I cant get it to work for the “//IF PAGE IS ONE OF ARRAY PAGENAMES” section 🙂 Any ideas?

    So first problem is limiting the amount of pages listed to 7.
    Second is getting a link to show up only on the last post of that page. Which links to another page which shows only 7 posts and then has a link to another page etc.

    thanks for any help btw.

    esmi

    @esmi

    Forum Moderator

    I’m not 100% sure if you can successfully paginate when using get_posts – mainly because I don’t think I’ve tried it myself. You could try replacing:

    $lastposts = get_posts('category=' . $i);

    with:

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $lastposts = get_posts('category=' . $i . '&posts_per_page=5');

    and see if that helps.There are also some tutorials on multiple Loops in the Resources section on http://codex.wordpress.org/The_Loop#Multiple_Loops You might find some ideas in there.

    I have tried this:

    http://jamestrusler.co.uk/wp-content/themes/jamestrusler/helpMe2.txt
    find : /*PROBLEMMM ISSS HEREEEEEE*/

    But it returns no posts. Any ideas why is_page isn’t working. I’m going crazy I think, I can’t solve simple thing :S.

    If you visit my page it returns 4 page names. If that helps at all lol :S.

    EDIT: I now have a working next button too. But because there is problem displaying the posts It does not work. view site for visual.

    EDIT: If I replace:

    if (is_page($pageNames[$i])) {?>

    with

    if (is_page($pageNames[$i])) continue;?>

    It outputs a post from 1 category 8 times.. I don’t get it 😀

    It’s not what I’m looking for, but thanks. Esmi was on the right lines. Perhaps She/He will know where I’m going wrong.

    I’m still stuck. 5 hours overall of trying. *cries*. Please refer to previous posts for information on my problem. I’m so grateful for the help.

    esmi

    @esmi

    Forum Moderator

    Can you confirm whether the code at http://jamestrusler.co.uk/wp-content/themes/jamestrusler/helpMe.txt is still being used? If not, drop a copy of the current file into the WordPress pastebin and post the pastebin url here. I’ll try and have another look at it.

    I’m kind of stuck now because i’m scared to touch my site just in case you’re checking it out. lol.

    Any thoughts or should I just scrap that whole part and be happy with what i coded before *looks with puppy eyes* ?

    esmi

    @esmi

    Forum Moderator

    I’m looking at the code again now. Is the is_page() conditional intended to check for a specific Page in that custom query on line 121? Only query_posts('category=' . $i . '&posts_per_page=1'); is going to pull in Posts not Pages. Try replacing:

    if (is_page($pageNames[$i])) {?>

    with:

    if ($post->post_title == $pageNames[$i])) {?>

    Ah, it is suppose to pull in certain posts if the website is currently on a certain page.

    for example:

    If it’s page “blog”, show only Blog posts. etc. (I got this part to work. It’s changing that whole loopy part to succesfully give me a goto next page link thats the problem)

    what i needed was, show only 1 Post on the first blog page, then have a next button that leads to another page with only 1 post. ie… pagination. If I wrote too many amazing blogs, I need them to go onto archive pages.

    (infact i want it to be 7 posts per page, but i can only test with 1 post per page, coz only 2 posts exist 🙂 )

    P.S I just changed that line. Removed the extra ) that was there. It shows the same result.

    🙁

    esmi

    @esmi

    Forum Moderator

    it is suppose to pull in certain posts if the website is currently on a certain page.

    Aha! In that case, the logic flow is incorrect. You need to test which page you’re on before you set up the custom query . Also, rather than loop through your Page array, you could try using:

    $page_title = wp_title('',false,'');
    if( in_array($page_title, $pageNames) ) :
    [ set up query ]
    [ do stuff ]
    endif;

    What should happen if you’re not on one of the pages in your array? Anything?

    Elsewhere, I’d suggest incorporating <?php wp_head();?> just before </head> and <?php wp_footer(); ?> just before </div></body>. Both are used by the core (and many plugins) to initiate specific actions.

    Sorry I’m coming to the party late, and this may not help, but you can paginate any array using the code in this template.

    Thankyou Esmi. You always save my ass.

    I “did a cowboy” (I heard somoene use this phrase.. apparently it means you get something to work then leave it alone but it might be the worst way… I cant believe I just explained that. *sighs*) on my website and got it to work. I was so happy, I completely forgot about including the default head and footer stuff..

    I knew there was an easier way of doing if page then do this post. But I couldn’t be bothered to check it out after I had got it to work.

    You know i’ll post again but you’ve got me started. hehe.

    Cheers once again!!! You’re a credit to wordpress!

Viewing 15 replies - 1 through 15 (of 42 total)
  • The topic ‘[Resolved] Pagination, Not sure what to do’ is closed to new replies.