Passer la navigation

[Résolu] Slider Dynamic Sources Not Working

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem:

I've created a view to display dynamic image sources in an image slider, even though I've selected dynamic sources, and it's supposed to be pulling images from that post only, every single post with this view is displaying the same images.

Solution:

You need to add a filter: limit the post view "Gallery Slider" to query only current "Plan Your Visit" post, for example:

https://toolset.com/forums/topic/slider-dynamic-sources-not-working/#post-2286497

Relevant Documentation:

https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query

This support ticket is created Il y a 4 years, 3 months. 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Fuseau horaire du supporter : Asia/Hong_Kong (GMT+08:00)

Ce sujet contient 2 réponses, a 2 voix.

Dernière mise à jour par melissaC-8 Il y a 4 years, 3 months.

Assisté par: Luo Yang.

Auteur
Publications
#2286239
Screen Shot 2022-02-07 at 3.31.09 PM.png
Screen Shot 2022-02-07 at 3.30.54 PM.png
screencapture-staging2-visitduboiscounty-wp-admin-admin-php-2022-02-07-15_28_53.png

I've created a view to display dynamic image sources in an image slider like you see on this page: lien caché

Even though I've selected dynamic sources, and it's supposed to be pulling images from that post only, every single post with this view is displaying the same images.

See this page for an example: lien caché
Instead of the train images, there should be an image of the Bed & Breakfast.

Another example where the images are wrong: lien caché

I'm attaching screenshots of my setup in case I've missed something.

#2286497

Hello,

You need to add a filter to limit the post view "Gallery Slider" to query only current "Plan Your Visit".

I have done below modifications in your website:
Dashboard-> Toolset-> Settings-> Custom code, add one item "slider-filter", with below codes:

add_filter('wpv_filter_query', function($query_args, $view_settings, $view_id){
  if($view_id == 223457){ // specific view ID
    $query_args['p'] = get_the_ID();
  }
  return $query_args;
}, 99, 3);

Please test again, check if it is what you want.

More help:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query
https://developer.wordpress.org/reference/classes/wp_query/#post-page-parameters

#2286837

Thank you! I'm not sure how I was supposed to know code needed to be added, but I'm glad the problem is resolved.