Support » Themes and Templates » How to paginate a secondary loop ?

  • yagraph


    Hi all,

    I’m doing a podcast website for an university, here :
    containing some podcast post showing episodes :
    syndicated through FeedWordPress on a PHP 5 server.

    To display episodes, I use a secondary loop in single.php when a post is in the podcast category, requesting for posts with the corresponding meta value (podcast_syndication_source)…
    Everything goes well, but… I cannot achieve to paginate this episodes inside the podcast post…

    here is my single.php :

    [Large code excerpt removed by moderator. Per forum rules, please use the pastebin for all large code excerpts. It works better anyway.]

    The problem is that if I try to go on the ‘Older Entries’ button, I go back to the first page (reseted I suppose), so I never see the second one…
    So I suppose that I have to store it in a variable like $episodes… but I can’t figure how to achieve it precisely…

    Another problem is that posts_nav_link() or any of its variant seem to do not work inside $episodes = new WP_Query.

    I used to use query_posts instead of $episodes = new WP_Query, but despite the fact that posts_nav_link() was working, it’s the same.

    Please bring me the light !
    Thanks in advance,

Viewing 2 replies - 1 through 2 (of 2 total)
  • yagraph


    Sorry, that’s right that’s a lot of code…
    So, I finally put the entire single.php file in the pastebin :
    It’s widely commented, so I hope it will be clear enough.



    ok, after hours of googling, I solved posts_nav_link() disappearing problem, and use WP_Query for each loop, witch is supposed to be cleaner :

    But I’m still stuck … the “Previous Posts” button send to “[same url]/page/2”, and that’s not what I want : I’d like to see the previous 10 posts with the same meta_value …

    Maybe this post should be put in the Advanced section ?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to paginate a secondary loop ?’ is closed to new replies.