• 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 Darren Cooney

    (@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.

    Thread Starter shubham291994

    (@shubham291994)

    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 Darren Cooney

    (@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.

    Thread Starter shubham291994

    (@shubham291994)

    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 Darren Cooney

    (@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 5 years, 3 months ago by Darren Cooney.
    Thread Starter shubham291994

    (@shubham291994)

    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 Darren Cooney

    (@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.

    Thread Starter shubham291994

    (@shubham291994)

    Thanks @dcooney

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

    Thanks,

    Thread Starter shubham291994

    (@shubham291994)

    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 Darren Cooney

    (@dcooney)

    Nice work @shubham291994 ??

    Thread Starter shubham291994

    (@shubham291994)

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

    • This reply was modified 5 years, 3 months ago by shubham291994.
Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Want to show total loaded post by total number of post’ is closed to new replies.