1

I'm outputting some images using a Matrix field, but they are outputting on frontend in a random order. I'm trying to output according to rows they are currently in.

I tried using sort and orderby Matrix field tags, but no luck.

Here's sample code:

{stash:content}
    {homepage_sliders}
        <li><img src="{image}" alt="{title}" /></li>
    {/homepage_sliders}
{/stash:content}

Ended up being a js issue with the flexslider script.

This wasn't working:

        $(window).load(function() {
            $('.flexslider').flexslider({
                animation: "slide"
            });
        });

Replaced with this and worked:

        $('.flexslider').flexslider({
            animation: "slide",
            start: function(slider){
              $('body').removeClass('loading');
            }
          });
2

Strange that you're getting a random output since orderby="id" is the default. Are you sure there isn't some kind of JavaScript that's reordering your fields on the front-end? You could try disabling JavaScript to verify that.

Otherwise you could try explicitly setting the id field as the orderby (which I've never had to do before).

{homepage_sliders orderby="id"}

but it definitely seems wrong.

There's also the fixed_order="" parameter which let's you specify the order of the ids

{homepage_sliders fixed_order="1|3|2|4"}
2
  • Definitely strange. Jarrett, you were on the right track with the js error. It was actually an issue with the flexslider script. Included my answer above. Thanks for the help. – frshjb373 Nov 21 '14 at 23:21
  • Had a similar issue on a site I built in 2013 and needed to update & it turned out to be exactly this. Thanks guys, saved me a lot of debugging time. – StvCummins Dec 18 '15 at 12:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.