Forums Forums Search & Filter Pro Custom query setup

Tagged: 

Viewing 9 posts - 1 through 9 (of 9 total)
  • Anonymous
    #229445

    Hi, Trevor. I’d contacted you previously about using the plugin with BB Themer (but my use-case was a bit far outside your scope). I’ve stepped outside Themer and have handcoded (to the best of my abilities) a basic query that initially displays the posts in the correct cluster (layout will come later). I set up a filter targeted to the CPT and added the filter with a do_shortcode.

    The filter appears, correctly showing the the drop-down the 2 posts that have the taxonomy to be filtered by (Location) but upon selecting that taxonomy, the pages refreshes (I want to stay on the same page) but there’s no filtering.

    Following is my code. Am I missing something or just a bad query setup? Or a bad filter setup?

    Thanks for taking a look,
    Tim

    =========

    <div class="fl-content-full container">
    	<div class="row team-badges" style="padding-top:150px;">
    		<?php echo do_shortcode('[searchandfilter id="1623"]'); ?>
    		<div class="fl-content col-md-12 teamtest">
    			<?php
    
                    $cats = get_terms( 
                        array(
                            'taxonomy' => 'teams',
                            'orderby' => 'menu_order',
                            'order' => 'ASC'
                        )
                    ); 
    
                    foreach ($cats as $cat) :
                    ?>
                    
    	                <h2><?php echo $cat->name; ?></h2>
    	                
    	            <?php
    
                    $peeps = new WP_Query( array(
                        'post_type' => 'people',
                        'orderby' => 'menu_order',
                        'order' => 'ASC',
                        'tax_query' => array( 
                            array( 
                                'taxonomy' => 'teams',
                                'field' => 'slug', 
                                'terms' => array($cat->slug),
                            )
                        ) 
                    ));
    
                    if ($peeps->have_posts()) :  while ($peeps->have_posts()) : $peeps->the_post();?>
    
                        <li>
                            <?php the_title(); ?>
                        </li>
    
                        <?php 
    	                endwhile;
    		            wp_reset_postdata();
    		                
    		        endif; 
    		        
    		        endforeach; 
    		    ?>
    
    		</div>
    	</div>
    </div>
    Anonymous
    #229446
    This reply has been marked as private.
    Trevor
    #229519

    I do not see any linking of the form to the query?

    Adding this, for example, to the arguments:

    'search_filter_id' => 1623,

    Anonymous
    #229555

    that did it! My next challenge is to hide “empty” categories, but that’s likely not in the scope of your great plugin.

    Thanks so much, very helpful.

    Trevor
    #229559

    If you want categories in our field to disappear if they are empty …

    … then in the General settings tab of the form:

    Set Auto Count (both settings) to ON

    And then in the Form UI:

    In each field set Hide Empty to ON

    Anonymous
    #229561

    ah, thanks, yeah, I should have clarified: I’m looking to hide the categories on the page (the H2 heads) if there are no posts in the job function grouping (such as Global Functions).

    Trevor
    #229564

    Ah, I am hoping this option will come with V3, due in Spring 2020. Is it OK to close this thread for now?

    Anonymous
    #229566

    yup, fine to close. I’ll keep hammering at this and see if I can wrangle it, but will keep an eye peeled up for updates to this end. Thanks!

    Trevor
    #229568

    Thanks for letting me know. I will close this thread for now.

Viewing 9 posts - 1 through 9 (of 9 total)