Forums Forums Search & Filter Pro Custom integration with categories

Viewing 5 posts - 1 through 5 (of 5 total)
  • Anonymous
    #120314

    I was attempting to add in the Search Filter ID to my existing WPQuery which went through some categories. Would there be a better approach tp getting this to work?

    $custom_terms = get_terms('wpsl_store_category');
    
    foreach($custom_terms as $custom_term) {
        wp_reset_query();
    	$args = array(
    		'post_type' => 'wpsl_stores',
    		'posts_per_page' => -1,
    		'orderby'=> 'title', 
    		'order' => 'ASC',
    		'tax_query' => array(
                array(
                    'taxonomy' => 'wpsl_store_category',
                    'field' => 'slug',
                    'terms' => $custom_term->slug,
                ),
            ),
            
         );
         $args['search_filter_id'] = 1478;  
    
         $loop = new WP_Query($args);
         if($loop->have_posts()) {
            echo '<h2>'.$custom_term->name.'</h2>';
    
            while($loop->have_posts()) : $loop->the_post();
                echo get_the_title();
    
            endwhile;
    
         }
    }
    
    Trevor
    #120337

    That is the way to do it, but it rather depends on what you are trying to achieve, and does that work? What Display Results method are you using?

    Anonymous
    #121056

    I set the Display Results to Custom. I put the code within a page template file and output the shortcake via PHP as well:

    echo do_shortcode('[searchandfilter id="1478"]');

    I’m just not getting any results showing:

    http://nmfma.identifiedmedia.com/?page_id=1481

    If I remove the $args['search_filter_id'] = 1478; then all results display.

    Trevor
    #121068
    This reply has been marked as private.
    Anonymous
    #122134

    Thanks for the help. Watch out for tinkering with Post Meta conditions.

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