Skip Navigation

[Resolved] Slider View with term filter as shortcode attribute in Elementor

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

Problem: I have two custom post types. On the Elementor template for post type A, I would like to display a slider View of post type B. I would like to filter post type B by a taxonomy term that has the same slug as post type A where the View is shown.

Solution: Use a shortcode to insert the View and set the term filter to respond to a shortcode attribute. Pass in the current post's slug to the term filter shortcode attribute using the wpv-post-slug shortcode:

[wpv-view name="zitateslider-with-dynamic-term-filter" wpvmeisterincat="[wpv-post-slug]"]
This support ticket is created 4 years, 4 months 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)

Tagged: 

This topic contains 4 replies, has 2 voices.

Last updated by michaelZ 4 years, 4 months ago.

Assisted by: Christian Cox.

Author
Posts
#1913185
Unbenannt.JPG

Hi dear Toolset-Team,

I'm trying to build a page with Elementor where I want to display a Slider View as dynamic Elementor Short Code field (Text field would be fine, too). The View is created by a custom post type for quotes. But if I select the Toolset field only the first quote is displayed. It does not slide on. If I click on the next-arrow a small loading circle shows up and never ends.

I need to have the view short code in a custom field for the respective person. If I insert the view shortcode directly it works, but then the person's elementor template can't be field dynamically with the right quotes...

hidden link

Could you please help with this issue? I'm kind of desperate.

Thanks and regards
Michael

#1913609

he View is created by a custom post type for quotes. But if I select the Toolset field only the first quote is displayed. It does not slide on. If I click on the next-arrow a small loading circle shows up and never ends.
Yes, it appears that including the View in a custom field like this and displaying it in an Elementor template leads to some JavaScript errors. Those errors prevent pagination from working correctly in this View.

If I insert the view shortcode directly it works, but then the person's elementor template can't be field dynamically with the right quotes...
Okay that might indicate a convenient solution is available. If the View works when placed directly in the template, we might be able to make the taxonomy term filter dynamic somehow, which would eliminate the need to place the View in a custom field. In this case, the View is shown on a Meister*In post, and the post slug is "paramahansa-yogananda". The View's Query Filter is set up to filter by a taxonomy term that has the same slug - "paramahansa-yogananda". That is convenient, because it allows us to use the current post slug to set the taxonomy term filter using a shortcode attribute. As a test, I created a duplicate of the View, you can see here: hidden link

I modified the taxonomy term Query Filter in this View so that it responds to a shortcode attribute wpvmeisterincat instead of using a static, predefined taxonomy term filter.

Then, I edited the Meister*Innen Elementor Template here:
hidden link
hidden link

I added a Text element just below the current slider. The Text element includes the duplicate View, using a shortcode, with the meisterincat shortcode attribute set by the current post slug:

[wpv-view name="zitateslider-yogananda" wpvmeisterincat="[wpv-post-slug]"]

Now you can see the duplicated Zitate slider here:
hidden link

So in theory, you can reuse the same View in every Meister*In post like this without creating multiple Views with specific term filters and storing each View in a Meister*In post custom field. But this approach only works if the Meister*In post slug is identical to its corresponding term slug, and the Zitate View filtering requirements are similar in each Meister*In post. Does that make sense? If the filtering requirements are different in other Meister*In posts, for example, you need to filter by two or three terms in on Meister*In post, then this approach will not work. If the term slugs and Meister*In post slugs are not always identical, then this approach will not work. Let me know what you think and we can go from there.

#1914315

Hello Christian,

thank you very much for your quick reply and help. I probably do not understand the points you made, so maybe you can give me a little further assistance. I just tried to set up another Meister*in and some new quotes associated with this one by the custom taxonomy.

So the second master is this one hidden link
His quotes are here
hidden link
hidden link

Still here hidden link one sees the quotes of Paramahansa Yogananda, not the ones of Vivekananda

So I do not understand how I can link the Quotes of one person to the right person. The logic should be: if person=a, than show only quotes from a.

Sorry, I'm not at all in coding, so I can't put better.

Thanks again, looking forward to your reply.
Michael

#1916481

Okay I have adjusted the Elementor template to display the correct View now. This View is used in the template:
hidden link

The View is placed in the template using this shortcode:

[wpv-view name="zitateslider-with-dynamic-term-filter" wpvmeisterincat="[wpv-post-slug]"]

Now, the View should appear on every Meister*In post, and the appropriate quotes should appear for every post. You do not need to adjust the code or the View, this should work for every Meister*In post. The catch is that the Meister*In post and Meister*In term must have the same slugs.

Does that make sense?

#1917287

Hello Christian,

thank you so much. It works great. Your support is way beyond what I would have ever expected.
Thanks, thanks, thanks!

So long
Michael