Support » Plugin: WordPress Infinite Scroll - Ajax Load More » Want to show total loaded post by total number of post

  • Resolved shubham291994

    (@shubham291994)


    Hello,

    Actually I need to show the loaded post by total number post. How can I do that, currently we get no of pages

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author dcooney

    (@dcooney)

    @shubham291994 Currently only number of pages is available.
    As seen here – https://connekthq.com/plugins/ajax-load-more/examples/results-text/
    This is on my list to update soon.

    • This reply was modified 1 month, 1 week ago by dcooney.
    • This reply was modified 1 month, 1 week ago by dcooney.

    Thank @dcooney

    Can you please suggest some option to do this, bro I need this functionality, tomorrow is my demo is there any filter or function by I can retrieve the current page number in alm_display_results filter.

    Thanks in advance

    Plugin Author dcooney

    (@dcooney)

    Nothing available in the filter.
    Total posts is available as a javascript variable on the page.

    But not sure what you are looking to display.
    Show me a design or eample of what you’re trying to do.

    Thanks,

    @dcooney I want to show like this “Showing 9 of 50 results” After clicking on load more button it will be “Showing 18 of 50 results” and so on.

    Plugin Author dcooney

    (@dcooney)

    Ok,
    Not possible using the result text at the moment.
    You could use ALM Variables and then use JS to pull data from the DOM element.
    https://connekthq.com/plugins/ajax-load-more/docs/variables/

    I dont have an example of this at the moment.

    • This reply was modified 1 month, 1 week ago by dcooney.

    ALM Variables only work in Repeater Template, is there any way we can use it in function.php?

    You could use ALM Variables and then use JS to pull data from the DOM element? 🙁
    Not understand properly 🙁

    Thanks

    Plugin Author dcooney

    (@dcooney)

    Yea it’s complicated.
    I was thinking this using the repeater template and the almComplete callback function.

    // Repeater Template
    <article class="item" data-item="<?php echo $alm_item; ?>" data-total="<?php echo $alm_found_posts; ?>">
    	<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
    	<p>Currently viewing item #<?php echo $alm_item; ?> of <?php echo $alm_found_posts; ?></p>
    </article>
    // JavaScript
    window.almComplete = function(alm){
       var item = alm.listing.querySelector('.item:last-child');
       var last = item.dataset.item;
       var total = item.dataset.total;
       console.log("Viewing" + last + " of " + total );
    };

    This is untested, but basically. It gets the last item in the ALM loop and read the variables.

    You could append this to an element somewhere on your page.

    Again, this is the best I could do for you as nothing is built in for this, just pages.

    Thanks @dcooney

    This is working fine but how can I call for next ajax request.

    Thanks,

    Thanks, @dcooney

    I have to change the code a little bit and then it will work.

    window.almComplete = function(alm){
    var container = document.querySelectorAll(“.alm-reveal”);
    container = container[container.length-1]
    var item = container.querySelector(‘.tf-item-for-t-post:last-child’);
    var last = item.dataset.item;
    var total = item.dataset.total;
    document.getElementById(“alm-search-results-text”).innerHTML = “Showing ” + last + ” of ” + total + ” results”;

    };

    Thanks again, bro.

    Plugin Author dcooney

    (@dcooney)

    Nice work @shubham291994 🙂

    Bhai, you made my day. Thank you so much for your instant reply 🙂

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