WordPress.org

Ready to get started?Download WordPress

Forums

Dynamically load next post and slide it in (3 posts)

  1. delFUEGO
    Member
    Posted 3 years ago #

    When I open X category, I have it display just 1 post from that category.

    What I need is than when I hit the "next post" button, the next post dynamically loads and "slides in" from one side, pushing the current post to the side. Same with previous button.

    I've been looking into sliders that support youtube videos (that's a must) but I wasn't able to find one that dynamically looks up if there exist a "next post" and load it on demand.

    Every slider I've seen just adds every post on the category and loads the content from them all at the same time.

    I don't need autostart, nor fancy transitions and all other eye candy stuff most sliders come with today.

    I just need to dynamically load up next post (if any) on request, and have it push the old one aside. Also, support youtube videos.

    Any ideas anyone?

  2. MandyWhite
    Member
    Posted 3 years ago #

    What you're describing is exactly how a javascript/ajax slider works. The posts are already loaded and the javascript reveals them by sliding the next post into view and hiding the others. It's honestly the only efficient method if you want it to slide without a page reload.

    If you can settle for simple paging, check the twentyten default template, and use their navigation code (at the top of loop.php). It will add next and previous to each page in a category if the prev/next page/post/image/media/etc. exists.

  3. MandyWhite
    Member
    Posted 3 years ago #

    Also, if you're not preloading the next/prev post, the slide effect is going to be lost because a script will have to query the database via http, retrieve the data, parse/format it, and replace the current page's content AFTER the user clicks next/prev. The user will likely see their cursor spinning as this occurs, and the user may never see the next page if there's a problem while the script is trying to pull this data together dynamically.

    If you're hoping for your content to be indexed by Google or any Search engine at all, replacing a page's main content via http, as you're suggesting, is the worst thing you can do. The method will make it impossible for a search engine to see your page's content if the content isn't simply hidden from humans or the content isn't retrieved/written as the page is reloaded to a new page. The bot will see a blank page because the content will not be hardcoded in the source. It won't find the next/prev pages either if you pull a post via http and have it magically replace the current page's center content without creating the physical html. This approach would create an illusion of content, visible by humans only. Sliders preload to enable the smooth sliding effect. There's no delay if the content exists in hidden form. This preload method allows users who have javascript turned off to still see all of the posts (no slide show but there's still content), and it allows search engines & screen readers to see all of the content in the category, as well. If you're not reloading the page by simply clicking "next/prev" to a new page of content and you're not sliding hidden content into view, then you're setting yourself up for a whole bunch of issues, like zero content for any visitor who is not using a modern visual browser with javascript and xml http+ajax enabled.

    With all this said, don't be silly -- you don't want what you think you want. There's a very good reason for why sliders preload & hide/unhide content.

Topic Closed

This topic has been closed to new replies.

About this Topic