• Resolved southafricanrob

    (@southafricanrob)


    Hi there,

    I was wondering if it would be possible to add an element after for example the 5th store in the results? (I want to add a message to get in touch if you cant see your store in the results).

    At the moment I am adding this message into my custom template which is called with the wpsl_listing_template filter, but of course it either shows above or below all the results.

    I assume I could achieve this fairly easily with a for each loop but I am not sure where this logic would go – could you point me in the direction of where the loop is that populates the template with the results?

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi there,

    The result list is generated via an AJAX call in JavaScript, so there is not a simple way that I can think of to insert that data every n stores without heavily modifying the core plugin files.

    You can take a look at that AJAX request in the wpsl-gmap.js file, the function is called makeAjaxRequest().

    Cheers!

    Hi again Rob,

    You know what? I just forgot to mention that actually, using ajaxComplete() you can count the number of <li> elements, and that way insert whatever you want at a custom location. Try that out!

    Thread Starter southafricanrob

    (@southafricanrob)

    Amazing – thanks for the  ajaxComplete() tip. Using this I was able to achieve exactly what I wanted – many thanks:

    $(document).ajaxComplete(function(event,request, settings){

    $("#wpsl-stores li:nth-child(5)").after("foobar");


    });

    Yes! That is pretty much it. Good’old jQuery still has some tricks up its sleeve ??

    Regards,

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Add element after n stores in the the results’ is closed to new replies.