Home › Forums › Pro Support › Carousel to replace Prev/Next?
- This topic has 8 replies, 3 voices, and was last updated 4 years, 4 months ago by
David Beckwith.
-
AuthorPosts
-
April 23, 2019 at 8:13 am #8915
Callista
ParticipantHi Tom,
Last question for a while, hopefully! I was thinking it would be great to replace the previous/next links at the bottom of my posts with a carousel that shows all the posts in that post’s category, going forward and backward in a loop, with the current post in the middle (but ideally hidden, because you’re already on that post). Is that even possible? Well, displaying ALL the posts might be a bit overkill, so maybe the previous 5 and next 5? Can we make what posts are displayed relative to the current post? If not, that’s fine, I can just stick with the previous/next links I currently have.
Thanks again!
Have a great day!
CallistaApril 23, 2019 at 6:41 pm #8940Tom
KeymasterHi there,
As of right now, it’s not possible to tell WPSP to display posts within the current category without using PHP. However, this is an option I’d like to add ASAP.
April 24, 2019 at 6:36 am #8950Callista
ParticipantHi Tom,
Yep! I’ve got the php going so it displays the posts in the same category – I found that in another thread. However, it always displays the same 10 or so posts every time, starting from the most recent. I’m wondering if it’s possible to have the posts displayed relative to the current post? Like the previous 5 and the next 5 posts?
Not a problem if it’s not – just would be a “nice to have” sort of feature.
Thanks!
CallistaApril 24, 2019 at 4:40 pm #8980Tom
KeymasterHmm, not sure if that’s possible. We could make it so they’re randomly ordered, though?
Let me know 🙂
April 25, 2019 at 6:00 am #8989Callista
ParticipantHi Tom,
Yeah, I didn’t think so but it doesn’t hurt to ask, right? 🙂
For now, I will take your suggestion of ordering the posts randomly (option in the settings page).
Thanks so much!
CallistaApril 25, 2019 at 4:11 pm #8997Tom
KeymasterNo problem! 🙂
April 25, 2019 at 4:29 pm #8999David Beckwith
ParticipantHi there,
not sure if this will fit your requirements, i am using this PHP snippet to hook in a list of related posts from the current post category:
<?php if ( is_single() ) { $cats = get_the_category(); $cat = $cats[0]; } else { $cat = get_category( get_query_var( 'cat' ) ); } $cat_slug = $cat->slug; $list = get_page_by_title( 'related', 'OBJECT', 'wp_show_posts' ); wpsp_display( $list->ID, 'tax_term="' . $cat_slug . '"' ); ?>
The ‘related’ in
$list = get_page_by_title( 'related', 'OBJECT', 'wp_show_posts' );
is the title of the WPSP list.May 2, 2019 at 6:00 am #9095Callista
ParticipantHi David!
Thanks for this. Is this different than the random posts option? How is it determining what posts are related? (I see that ‘related’ is the title of the WPSP list – do you mean that you title the WPSP list ‘related’ or do you change the code to reflect the title of the list? And, is your WPSP list pulling all/random posts, or are you somehow specifying which posts are ‘related’?)
I’m super interested in generating related posts, especially since I tried using JetPack’s version but could not figure out how to get it to display the way I wanted.
Thanks again!
CallistaMay 2, 2019 at 11:18 am #9101David Beckwith
ParticipantI am using it here in this upcoming GP Site:
https://merch.assemblewp.com/plugins/
The list is hooked into the bottom of the single post.
It gets the first category of the post you are currently viewing. It then filters the list using that category. So the relationship is by Category.The list itself you can configure anyhow you want, just leave out the taxonomy filter, but the name of the list must match that in the code. In my case that is ‘related’
-
AuthorPosts
- You must be logged in to reply to this topic.