Archived topic
Display of previous and next posts associated with the author
3 replies · Started by Takeru on March 10, 2022
I am reprinting a question I recently asked on GenerateBlockcommunity.
I would like to display the previous and next posts associated with an author.
I was given the following code, but had the following two problems
add_filter( "get_next_post_where", function($where, $in_same_term, $excluded_terms, $taxonomy, $post){
$where .= " AND p.post_author='".$post->post_author."'";
return $where;
}, 10, 5);
add_filter( "get_previous_post_where", function($where, $in_same_term, $excluded_terms, $taxonomy, $post){
$where .= " AND p.post_author='".$post->post_author."'";
return $where;
}, 10, 5);
First, the title of the next post is displayed correctly, but the link for does not work.
Second, the dates of the previous and next posts show the latest date.
Please let me know the solution.
Hi TK,
Thank you for reaching out to us here. With regards to the issue, may we know how you’re retrieving the date and the link to the next posts?
I tested this on my test website with the following settings and it appears to be working as expected from my end:
https://share.getcloudapp.com/NQuNq5bm
https://share.getcloudapp.com/Bluoy2pd
Here it is working as it should: https://share.getcloudapp.com/Z4u7xpww
Kindly let us know. Hope to hear from you soon. :)
Sorry!
I was mistaken and made a configuration error, and when I set it up correctly it worked fine😅.
Glad it's working as it should now! Feel free to reach out anytime if you’ll need assistance with anything else. :)