Support Forums

The forums are closed and will be removed when we launch our new site.

Looking for support? You can access the support system via your account.

Forums Forums Search & Filter Pro Shortcode results: don't display results until click

Tagged: 

Viewing 10 posts - 1 through 10 (of 21 total)
  • Will Kramer
    #51650

    Hi – I am using a shortcode form and shortcode results on the same page (two separate columns). I am also using your template results.php file. Right now, as soon as you go to the page, it shows the form, and all entries that are available under results… then, when you click on an option in the form, it starts to actually filter the proper results.

    Is it possible to have the results shortcode not actually display any results until the first option is clicked on the form? (I am also using auto submit). I would like the results area to just be blank until someone starts interacting with the search form.

    Will Kramer
    #51719
    This reply has been marked as private.
    Will Kramer
    #51722
    This reply has been marked as private.
    Trevor Moderator
    #51732

    Hi

    Sadly the code you posted has gotten mangled by the forum script 🙁

    Before the block of code and after it needs to be a code tag. On my screen, above where I am typing this, I can see the formatting buttons (bold, italic etc) and the last but one is the code tag button. Press this once before and once after the code. You will see it actually types a ‘back tick’, if you can see the button bar that is. Otherwise, on my keyboard, the symbols button to the left of the 1 key also types the same back tick.

    Can you re-post the results.php code?

    Will Kramer
    #51736
    This reply has been marked as private.
    Trevor Moderator
    #51738

    Hi

    I found two errors (one was ours, one yours), so here is the fixed code (I do not know if this will work):

    <?php
    /**
     * Search & Filter Pro
     *
     * Sample Results Template
     *
     * @package   Search_Filter
     * @author    Ross Morsali
     * @link      http://www.designsandcode.com/
     * @copyright 2015 Designs & Code
     *
     * Note: these templates are not full page templates, rather
     * just an encaspulation of the your results loop which should
     * be inserted in to other pages by using a shortcode - think
     * of it as a template part
     *
     * This template is an absolute base example showing you what
     * you can do, for more customisation see the WordPress docs
     * and using template tags -
     *
     * http://codex.wordpress.org/Template_Tags
     *
     */
    
    if ( $query->have_posts() ) {
        global $searchandfilter;
        $sf_current_query = $searchandfilter->get(44)->current_query();
        if ($sf_current_query->is_filtered()) {
            ?>
    
            <?php echo $query->found_posts; ?> Firm(s) Meet All Selected Criteria<br/>
    
            <div class="pagination">
    
                <div class="nav-previous"><?php next_posts_link('Older posts', $query->max_num_pages); ?></div>
                <div class="nav-next"><?php previous_posts_link('Newer posts'); ?></div>
                <?php
                /* example code for using the wp_pagenavi plugin */
                if (function_exists('wp_pagenavi')) {
                    echo "<br />";
                    wp_pagenavi(array('query' => $query));
                }
                ?>
            </div>
    
            <?php
            while ($query->have_posts()) {
                $query->the_post();
    
                ?>
                <div>
                    <h6><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h6>
    
                    <p><?php the_tags(); ?></p>
    
                </div>
    
                <hr/>
                <?php
            }
            ?>
    
            <div class="pagination">
    
                <div class="nav-previous"><?php next_posts_link('Older posts', $query->max_num_pages); ?></div>
                <div class="nav-next"><?php previous_posts_link('Newer posts'); ?></div>
                <?php
                /* example code for using the wp_pagenavi plugin */
                if (function_exists('wp_pagenavi')) {
                    echo "<br />";
                    wp_pagenavi(array('query' => $query));
                }
                ?>
            </div>
            <?php
        } else {
            echo "No firms meet all of your criteria. Try unchecking some boxes.";
        }
    }
    ?>
    Will Kramer
    #51739
    This reply has been marked as private.
    Trevor Moderator
    #51787

    Try changing this:

    if ( $query->have_posts() ) {
    

    to this:

    if ( !$query->have_posts() ) {
    

    Maybe?

    Will Kramer
    #51929
    This reply has been marked as private.
Viewing 10 posts - 1 through 10 (of 21 total)

The topic ‘Shortcode results: don't display results until click’ is closed to new replies.