Support » Plugin: Responsive Slider by MetaSlider - Slider and Carousel Plugin for WordPress » random / randomized order does not work in static html

  • Resolved schubi63

    (@schubi63)


    Hi folks,

    first: thanks for the great work for MetaSlider.

    I develop a website local on my notebook (XAMPP, Mac). I set my (MetaSlider) slides to display the content randomly. That work’s fine on my local system.

    After exporting the whole website content via the WordPress plugin “WP2Static” (https://wp2static.com/) and moving it to the webspace: the slides work. Except the random function. The images have always the same order.

    Is there anything I can do to fix this?
    Or is it impossible because of how the randomization is implemented?

    Thank you so much for your time and hopefully your help.

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 21 total)
  • Plugin Contributor kbatdorf

    (@kbat82)

    Hi,

    Unfortunately the randomness is done on the server. You could try adding this to your functions.php file to instruct FlexSlider to randomize them:

    add_filter('metaslider_flex_slider_parameters', function($options, $slider_id) {
        $options['randomize'] = 'true';
        return $options;
    }, 10, 2);

    @kbat82 First of all: thank you very much for answering! Now I know that I didn’t do anything wrong.

    Maybe I’m a bit too less progger than knowing what to do next. I searched for the functions.php but found many. A general one under wp-content, in the theme, but also lots of in several plugins folders. But there is none under plguins/ml-slider.

    Do I have to create a functions.php there?

    And should I paste the code, you gave me, directly into it? Because of “metaslider_flex_slider_parameters” I’m afraid not, right??

    Thanks in advance!

    Plugin Contributor kbatdorf

    (@kbat82)

    Hi,

    Typically people will add it to the functions.php file in their theme or a child theme. It’s safe to add to your theme so long as you don’t need to update your theme from its source later on.

    If that wont work, the next best way is to add it as an mu-plugin which is a file you add to your server that contains little functions like this.

    I know it’s a little bit confusing so let me know if you get stuck somewhere.

    @kbat82 I don’t know how and what that function does, but it works. Thank you very very much!

    The only little thing, there is a little flicker when loading / refreshing the site.
    Is it possible to have a delay / fade-in, that this won’t happen?

    Plugin Contributor kbatdorf

    (@kbat82)

    Hi,

    You could try using a lazy loading plugin. Otherwise you might have some luck cropping the images a little smaller. We don’t have anything set up at this time to include a fade-in delay.

    Hi @kbat82

    with the code you gave me meta sliders are randomized in static version. Which is cool. But it influences all meta sliders.

    Is it possible to have only those randomized, which are set to random in the slide specific settings?

    Plugin Contributor kbatdorf

    (@kbat82)

    Hi,

    You can try to match the slideshow ID. Where ‘123’ is the id of your slideshow.

    add_filter('metaslider_flex_slider_parameters', function($options, $slider_id) {
        if ($slider_id != '123') return $options;
        $options['randomize'] = 'true';
        return $options;
    }, 10, 2);

    Works! Thank you so much!

    How does the if condition look like, if I want to have several meta-sliders excluded?

    …hmmm, I thought it works. But it seems that it does not work – I checked the ID twice now, and exported the content several times. But all MS-Slider are still randomized.

    Do I understand something wrong?

    Plugin Contributor kbatdorf

    (@kbat82)

    Hi,

    Can you show me the exact code you used?

    Hi!

    Sorry for the delay. I added

    add_filter(‘metaslider_flex_slider_parameters’, function($options, $slider_id) {
    if ($slider_id != ‘1059’) return $options;
    $options[‘randomize’] = ‘true’;
    return $options;
    }, 10, 2);

    to the functions.php under wp-content/themes/myTheme

    Was it the wrong functions.php? SHould I have used a different one – e.g. under wp-includes?

    Plugin Contributor kbatdorf

    (@kbat82)

    Hi,

    Double check the slideshow ID. On the /offers/ page I don’t see a slideshow with that ID. I see: 1283, 1289, 1347, 1322

    Hi @kbat82

    yeah, you are right. The MetaSlides on the offers page can all be randomized. That’s fine. But I wanted to exclude the MetaSlider on the start page.

    https://www.herrschubert.de/

    Plugin Contributor kbatdorf

    (@kbat82)

    Hi,

    I wonder if this has to do with the static page processing? Can you try to check what the ID that’s in $slider_id is?

    add_filter('metaslider_flex_slider_parameters', function($options, $slider_id) {
        echo '<!--';
        var_dump($slider_id);
        echo '-->';
        if ($slider_id != '123') return $options;
        $options['randomize'] = 'true';
        return $options;
    }, 10, 2);

    That should dump out the ID (or maybe something else!) into an HTML comment that you can view by inspecting the HTML source.

    Hi @kbat82

    I added your code. Here is an excerpt of the HTML source:

    <div class=”entry-content” itemprop=”text”>
    <!–string(4) “1059”
    –><p>Ich habe mein „Warum“ gefunden – ich möchte Menschen zum Strahlen bringen.</p>
    <p>Ich habe unwahrscheinlich Spaß mit Menschen zu arbeiten. Tauche gerne für eine Weile in deren Welt ein. Freue mich jedesmal, die Individualität die in jedem von uns steckt, zu entdecken. Und wenn dieser eine, besondere Augenblick in Deinem Foto festgehalten ist – bringt das mein Herz zum Singen.</p>
    <div id=”metaslider-id-1059″ style=”width: 100%; margin: 0 auto;” class=”ml-slider-3-17-4 metaslider metaslider-flex metaslider-1059 ml-slider myMetaSlider”>
    <div id=”metaslider_container_1059″>
    <div id=”metaslider_1059″>

    It’s obviously the correct ID 1059 right?

Viewing 15 replies - 1 through 15 (of 21 total)
  • You must be logged in to reply to this topic.