Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other [WordPress] Load more posts on click

  • This topic is empty.
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #170059
    mikes02
    Participant

    I have a page that is using a custom query to display the 6 latest posts from a specific category, at the bottom I would like to have a button that when clicked it loads the next 6 articles, I have scoured the internet for something to accomplish this and it seems none of the tutorials work with custom queries or will load the next set of articles on click, I don’t want to replace the 6 articles that show originally, I just want to load in 6 more, and keep the process repeating until there are no articles left. Any ideas would be greatly appreciated.

    #170065
    nixnerd
    Participant

    Dude, I gotta ask, why wouldn’t you just use infinite scroll? From a UI/UX standpoint, scroll is less steps than clicking and they will just keep loading forever. They’ll even loop around to the beginning! I’m pretty sure you can hack that to stop when it’s reached the oldest post but if not… viola, there you go.

    #170066
    mikes02
    Participant

    Because it isn’t the functionality that was asked for, I am looking for a way to load more on click.

    #170073
    John
    Participant

    NM

    #170074
    mikes02
    Participant

    That’s not at all what I’m asking about.

    #170080
    nixnerd
    Participant

    Because it isn’t the functionality that was asked for

    K. Sorry. Just trying to suggest something easier. My bad.

    I don’t think there’s an easy way of accomplishing this, nor do I think there is just one way. You could look at the infinite scroll code and create a function to trigger it upon the clicking of a button, rather than scrolling. You could make a container that has a height of 0 until said button is clicked. Again… this will need to be a JS function. Obviously this container will hold the other posts. Upon clicking it, the height will go from ‘0’ to ‘auto’.

    What I’m trying to say is… this will require a mix of PHP, CSS and JS/Jquery. There MIGHT be a plugin that does this. Try looking. But, if you have to build it yourself. There is n number of ways to do that. Pick your poison.

    BTW, what are you looking at in your photo?

    #186848
    jekkilekki
    Participant

    I’m also looking to do the same thing in my plugin. Did you ever figure this out?

    I found this link about using AJAX to do it. Going to have a look at it and see if I can make it work.

    Also, here’s some similar code (maybe the same) on GitHub.

    #186849
    Alen
    Participant

    I’m on mobile now, but this https://wordpress.org/plugins/ajax-load-more/ I’ve worked with and it should do what you require.

    #236058
    GMK Hussain
    Participant
    #236062
    GMK Hussain
    Participant
Viewing 10 posts - 1 through 10 (of 10 total)
  • The forum ‘Other’ is closed to new topics and replies.