Timeline for Load more posts (Ajax) in tabbed sidebar on single.php
Current License: CC BY-SA 3.0
9 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Apr 13, 2017 at 12:37 | history | edited | CommunityBot |
replaced http://wordpress.stackexchange.com/ with https://wordpress.stackexchange.com/
|
|
Sep 10, 2014 at 16:00 | answer | added | Kevin | timeline score: 1 | |
Nov 28, 2013 at 3:48 | comment | added | Milo |
there are a few ways you could do this. since you're just returning html from your function, it may be easiest to insert some sort of element, or wrap the returned posts in an element and give it a class like "last" when it's the last group of posts, then you can check if the returned html has that class and hide the button. have a look at the query object to determine when you're on the last page of posts - check if $wp_query->max_num_pages is equal to $wp_query->query_vars['paged'] in your ajax template to know you're on the last page.
|
|
Nov 26, 2013 at 21:50 | comment | added | user11898019 | Sorry to bother you again. I've got one more question. Is it possible to hide the load button if there are no more post to display? | |
Nov 25, 2013 at 16:53 | comment | added | Milo |
You'd use the same method, but change it to count the number of whatever element you're inserting, so in your case something like $('#new li').length . that's really a jQuery question though. also note, your li s should be wrapped in a ol , ul , or menu to be valid html.
|
|
Nov 25, 2013 at 16:48 | comment | added | user11898019 | -oops doublepost- | |
Nov 25, 2013 at 16:48 | comment | added | user11898019 |
Jeez, I'm an idiot. Totally overlooked that. Ok the load more button works now. But I have to change the original var postoffset = $('.post').length; to a number (I assume it only counts one post on single.php.). That doesn't bother me though, but is it possible to get pagination working as well? Since clicking the button only loads the same posts.
|
|
Nov 25, 2013 at 16:27 | comment | added | Milo |
the ID of your anchor should be id="blog-more" , not id="#blog-more" .
|
|
Nov 25, 2013 at 16:22 | history | asked | user11898019 | CC BY-SA 3.0 |