• Resolved kureeru

    (@kureeru)


    Hello,

    I have 2 issues with the plugin:

    1. On my website, my buttons container have a ::before and ::after to give a special design, and I want to keep it. But in the blog page, if there is no more article to show after clicking the “load more” button, the class “done” is given to the button and not the button container (so I can’t hide my complete button and change the ::after, ::before). I would like to know if it’s possible to give the button container (.alm-load-more-btn) a class when there is no more post to load?

    2. The search page is not working correctly. I’ve tried the code on this page https://connekthq.com/plugins/ajax-load-more/examples/search-results/#code but I doesn’t work for me. After a search, if it has post, the button is shown but the posts aren’t displayed but if I type the value given to the $term, the search result is good, the articles are displayed. I’m using the WordPress search widget, I don’t know if it’s the problem?

    Thanks for your help and sorry for my broken English.

    Have a nice day!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Darren Cooney

    (@dcooney)

    Hi @kureeru,

    1. Since this is a custom button you could use the almDone JavaScript callback for this.
      https://connekthq.com/plugins/ajax-load-more/docs/callback-functions/#done
    2. I’m using the WordPress search widget, I don’t know if it’s the problem?

      It could be, how are you passing the search term to Ajax Load More?

    Thread Starter kureeru

    (@kureeru)

    Hi @dcooney !

    Thanks for your answers, my first issue is resolved !

    For the second issue, I tested with a simple form :

    <form role="search" method="get" id="searchform" class="searchform" action="<?php echo home_url( '/' ); ?>">
       <div>
          <label class="screen-reader-text" for="s">Search for:</label>
          <input type="text" value="" name="s" id="s" />
          <input type="submit" id="searchsubmit" value="Search" />
       </div>
    </form>

    But I get the same errors that the WordPress search widget.

    This is how I display the posts in the search.php :

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post();?>
       <?php endwhile; ?>
       <?php $term = $_GET['term'];if(empty($term)){$term = 'test';} ?>
       <?php echo do_shortcode('[ajax_load_more search="'. $term .'" post_type="post" posts_per_page="6" scroll="false" button_label="Voir plus d\'articles" button_loading_label="Chargement..."]'); ?>
    <?php else : echo 'Not posts found'; ?>
    <?php endif; ?>

    I hope it can help you to understand where my problem can come from.
    Again thanks for your help !

    Plugin Author Darren Cooney

    (@dcooney)

    Hi @kureeru,
    The issue is the following line:
    <?php $term = $_GET['term'];if(empty($term)){$term = 'test';} ?>

    $_GET['term'] is the querystring value, but on default WP search use $_GET['s']

    Or the default search template, you should use the following:
    <?php $term = $_GET['s'];if(empty($term)){$term = 'test';} ?>

    Hope this helps!

    Thread Starter kureeru

    (@kureeru)

    Hi @dcooney,

    Oh I didn’t know! I tested it and it works!

    Thanks again for your help, all issues are clear now!

    Have a nice day

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Hide the button container when no posts and button issues with search’ is closed to new replies.