[Support request] infinite ctp loop

Home Forums Support [Support request] infinite ctp loop

Home Forums Support infinite ctp loop

  • This topic has 6 replies, 2 voices, and was last updated 5 years ago by dasigna.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #241333
    dasigna

    hi tom,

    great help already on this post making cpts behave as normal posts with next/prev-links. works flawlessly

    but now there is a new upcoming question:
    can one make that an infinite loop – so that when reached the last post in single view there will still be some link to the next cpt (in that case the first again) and vice versa???

    the thing is, that when starting to view one post ‘in the middle’ of the post list you wont get to view all by ‘scrolling’ just to one direction … get what i mean?

    have already tried out inserting various snipplets found in depth of the web, but they do not seem to work as intended or maybe interfere in some way with the code given i the above link (this one).

    any help possible to solve/achieve this?

    thanks in advance.

    #241427
    Tom
    Lead Developer
    Lead Developer

    It looks like it’s possible, but requires custom code: https://gist.github.com/banago/5603826

    You would need to overwrite the generate_content_nav() function found in template-tags.php.

    Specifically you would need to replace anywhere the previous_post_link() and next_post_link() functions are called.

    #241473
    dasigna

    feared an answer like this …

    It looks like it’s possible, but requires custom code: https://gist.github.com/banago/5603826

    … one of those i’ve tried – but didnt work πŸ™‚
    where to put this thing exactly? functions.php?

    before again running into trouble: any more detailed hints possible?? (not that hero of coding…!)

    You would need to overwrite the generate_content_nav() function found in template-tags.php.

    … found in ‘/gp/inc’ ? that thing is big. what to replace with what else? …
    copy, edit and put into child? seems tricky regarding updates.

    Specifically you would need to replace anywhere the previous_post_link() and next_post_link() functions are called.

    … again, same question … πŸ™‚
    location must be hopefully only in this area <?php if ( is_single() ) : // navigation links for single posts ?> ??

    kinda standing on shaky ground for me – sounds as if i should keep my hands off of that… πŸ™

    no detailed tut for this???

    #241513
    Tom
    Lead Developer
    Lead Developer

    It’s definitely not an easy thing you’re getting yourself into πŸ˜‰

    First, copy this entire function (generate_content_nav) and add it to your child theme/custom plugin: https://github.com/tomusborne/GeneratePress/blob/1.3.40/inc/template-tags.php#L57-L108

    Then, replace these two lines with the code in that post: https://github.com/tomusborne/GeneratePress/blob/1.3.40/inc/template-tags.php#L87-L88

    #241616
    dasigna

    … youre getting lots of requests – have to search the thread again …

    so for the current case:
    got it implemented and worked somehow – infinite is there in priciple πŸ™‚

    but ten two things occur:
    1. having to define two different cpts for looping separately wich does not work really well…
    always get issues either with looping trough both cpts at once or getting stuck at first or last cpt of one kind.
    2. the formatting and display of the post title is gone with the tweak, so i thought it would be some good idea to put in the link calls from you. again works partially but causes some issues with the echo on frontend: loosing links, title not showing…

    so for the moment i am pausing the thing after spending some hours on it. by now seems nearly inachieveable with my weak knowledges. maybe theres one that might take a look on it… πŸ˜‰

    would be a great thing but turns out to be really hard.
    (why cant coding be drag’n drop too??? …!)

    many thanks for the moment – myself has to take some break for now!

    #241743
    Tom
    Lead Developer
    Lead Developer

    It’s been a busy month so far in the forum πŸ™‚

    If I find a little time I’ll try to implement it myself to see if I can help with more code in here. It’s definitely a difficult thing to do – I’m surprised there isn’t a built in filter in WordPress to handle it, as it’s actually a good idea.

    #241938
    dasigna

    yeah, wondering too why this is an native option within WP… even more since the call seems to be there already.

    anyway, cant get it to work the way intended right now.
    if youre interested and got the time it would be great!! might provide you with a link to the site released these days with the demand for that – prework still in custom functions.php but commented out.

    let me know πŸ™‚

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.