Skip Navigation

[Resolved] I Need to Create a Content Slider That is Conditional Upon Post Category

This thread is resolved. Here is a description of the problem and solution.

Problem: I have a slider View that uses a post category filter, but the View still appears on posts in other categories.

Solution: Use conditional HTML to show or hide a View based on some criteria like current post category. Use a post filter to modify the results displayed in the View.

Relevant Documentation:
https://toolset.com/documentation/user-guides/creating-sliders-with-types-and-views/
https://toolset.com/documentation/user-guides/filtering-views-by-taxonomy/
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/

This support ticket is created 6 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 12 replies, has 2 voices.

Last updated by adamR-11 5 years, 11 months ago.

Assisted by: Christian Cox.

Author
Posts
#1183063
1.png

Tell us what you are trying to do?

Hi, I'm trying to create a content slider called "recommended articles", to appear at the bottom of a single post. The site I'm working on has 10 categories. Each slider is different, depending upon the category that the post is in.

Is there any documentation that you are following?

Toolset knowledge base.

Is there a similar example that we can see?

I already built this on a site using Beaver Themer. However, I discovered that Beaver Themer is not compatible with WPML. Therefore, I want to rebuild this with Toolset.

You can see what I did here (it's in Hebrew):

hidden link

What is the link to your site?

hidden link

#1183153
Screen Shot 2019-01-13 at 4.30.18 PM.png

The site I'm working on has 10 categories. Each slider is different, depending upon the category that the post is in.
You can use Views to create a Slider, and add a Query Filter based on taxonomy (category) term. You can configure that Query Filter to be set by the current page's terms (see the screenshot here). Then only content that matches the current post's terms will be shown in the Slider. Once you have created this View, you can insert it in the template you have created for this post type, using the Fields and Views button.

If you'd like more information about creating sliders with Views, please see our documentation here:
https://toolset.com/documentation/user-guides/creating-sliders-with-types-and-views/

If you'd like more information about filtering content by taxonomy, see our documentation here:
https://toolset.com/documentation/user-guides/filtering-views-by-taxonomy/

#1189712

Hi, I tried sorting the view I created by category.

It is still appearing in other categories that I did not associate it with.

#1189716

How do I reopen this ticket? I was sick last week and unable to follow up on this.

#1189850

Hi, I tried sorting the view I created by category.
Well sorting and filtering are different things, so maybe there was a miscommunication here. If I understand your explanation, you need to add a Query Filter, separate from sorting. If you cannot see the Query Filter in the View editor screen, scroll to the top right corner and click "Screen Options". You can activate the Query Filter panel here.

If that's still not working as expected, I'll be glad to log in to your wp-admin area and take a closer look. Please provide login credentials in the private reply fields here.

#1190536

Thank you. After examining your site and carefully reading your comments again, I realize I do not understand completely. I need a bit more clarification from you. You said you want to have 10 different sliders, based on the category of the current post. Please explain more about the contents of these sliders, and how the contents relate to the current post. Let's assume your post categories include "red", "blue", and "green".
- When a User visits a post in the "red" category, what content will exist in the slider? Are they posts in the same post type, or posts in another post type, or what?
- Will the content shown in the slider content also have the "red" category term, or is there some other way the content is related to the current post?
- What if the current post is in multiple categories, like "red" and "blue"?

#1191584

Thanks.

When a User (not a registered user, by the way) visits a post in the "red" category, the slider will display more articles from the "red" category. As in "you might also like these articles..." These would be posts in the same post type.

The content shown in the slider will have the "red" category term. That is how it is related to the current post.

If the current post is in multiple categories, like "red" and "blue", the slider show content that is from the "red" and "blue" categories.

#1191634

When a User (not a registered user, by the way) visits a post in the "red" category, the slider will display more articles from the "red" category. As in "you might also like these articles..." These would be posts in the same post type.
Okay this is essentially what I was describing in my response here: https://toolset.com/forums/topic/i-need-to-create-a-content-slider-that-is-conditional-upon-post-category/#post-1183153

I see one View:
hidden link

The View and taxonomy filter are configured to display "Posts" associated to one specific term:
הגירה לישראל
(Immigration to Israel, in English)

Your Content Template for Posts contains this View:
hidden link

So if you want the View to respond to the terms associated with the current Post, you must adjust the taxonomy term filter as I described earlier. Set it up so that the term filter is determined by the page where this View is shown. Please carefully read my response here, and check the screenshot:
https://toolset.com/forums/topic/i-need-to-create-a-content-slider-that-is-conditional-upon-post-category/#post-1183153
My example taxonomy is called "Book taxes" but yours will be "Categories".

Once you have made that adjustment, please let me know which results are not accurate, and why. Thanks for your help. I do not read Hebrew so it is a challenge for me to understand which results should be correct.

#1192472
4BE689C0-29DE-475E-B5E9-FAD5675C814E.jpg

Thanks.

It's my understanding that the View that I created is all set up properly in regards to the Query Filter (see attached image).

The following link is of a post that is in a different category, yet still displays the content slider: hidden link

#1192658

The following link is of a post that is in a different category, yet still displays the content slider:
Right, because the Query Filter does not determine where the View appears, it determines which posts appear in the results. You're confusing a Query Filter with conditional display of a View.

1. Conditional display of the View means you must create 10 different Views, each with a different Query Filter, and then write conditional HTML logic to show different Views in different posts. More about conditional HTML: https://toolset.com/documentation/user-guides/conditional-html-output-in-views/

2. A Query Filter based on the current post lets you create 1 View, and place the same View in all posts. It's more efficient and less work for you.

It's my understanding that the View that I created is all set up properly in regards to the Query Filter (see attached image).
No, it's not quite right. Your Query Filter is configured to only display one static category of results. If you want the View to respond to the terms associated with the current Post, you must adjust the taxonomy term filter. Set it up so that the taxonomy term filter is determined by the page where this View is shown. Please carefully read my response here for an example and screenshot of the filter options:
https://toolset.com/forums/topic/i-need-to-create-a-content-slider-that-is-conditional-upon-post-category/#post-1183153

#1193144
2.png
1.png

Thank you! I finally got it. Problem #1 solved. I still have 8 problems to go(!).

The next problem - the design changes when the slider moves.

I designed what the slider should look like in Beaver Builder, but the design looks different when the slider moves:
hidden link

See the attached images.

Is there a way for the slide to retain its design when it slides?

New threads created by Christian Cox and linked to this one are listed below:

https://toolset.com/forums/topic/second-page-in-slider-view-is-not-formatted-correctly/

#1193160

Great, we can discuss the styling issue in the new ticket. Our policy is to address one issue per ticket - it helps us keep the forum organized. Thanks!

#1207014

My issue is resolved now. Thank you!