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 Custome query

Viewing 3 posts - 1 through 3 (of 3 total)
  • Lee Wilson
    #212046

    Hi there,

    I can get things working if I use the shortcode approach, utilising SAF’s own templates. However, I need to filter results displaying on the archive page, there is a basically an ACF checkbox ‘Show on the A-Z page’ (show_in_a_z_list), so I basically need to try and get SAF working with my custom archive page, unless I can make use of ACF on SAF’s template file?

    Here is the code in my template, the SAF’s filters display, I just can get the AJAX side of things working, appreciate any help…

    <?php
    
    $posts = get_posts(array(
     'numberposts'	=> -1,
     'post_type'		=> 'brands',
     'meta_query'	=> array(
    	 'relation'		=> 'AND',
    	 array(
    		 'key'	  	=> 'show_in_a_z_list',
    		 'value'	  	=> '1',
    		 'compare' 	=> '=',
    	 ),
     ),
    ));
    
    if( $posts ): ?>
    	<?php echo do_shortcode( '[searchandfilter id="1132"]' ); ?>
    <?php echo do_shortcode( '[searchandfilter id="1132" show="results"]' ); ?>
    
    <section class="blocks">
    			<?php $i = 1; ?>
    <?php foreach( $posts as $post ):
    
    	setup_postdata( $post );
    	?>
    <div class="block-<?php echo $i++; ?>">
    	<a href="<?php the_permalink(); ?>">
    	<article>
    					<?php $image = get_field( 'image' ); ?>
    					<?php if ( $image ) { ?>
    						<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
    					<?php } ?>
    	</article>
    	</a>
    	</div>
    <?php endforeach; ?>
    
    </section>
    
    <?php wp_reset_postdata(); ?>
    
    <?php endif; ?>
    Trevor Moderator
    #212123

    I think I understand. You would probably be better off using our Shortcode display results method on a real WordPress page instead of creating your own archive template.

    If your goal is to only shows posts that have the meta key ‘show_in_a_z_list’ set a ‘1’ then you can do this in the Post Meta settings tab of the form. It might need to look like this:

    https://www.screencast.com/t/2y2xrZyoYM

    OR this (I am not sure which would work):

    https://www.screencast.com/t/BoMkAG3yHi

    If you need to modify our results.php template the guide is here:

    https://searchandfilter.com/documentation/search-results/using-a-shortcode/#customising-the-results

    If you need to output the value of an ACF field, and give it a label, the code shown in this post might help:

    https://support.searchandfilter.com/forums/topic/output-acf-post-object-fields-in-results/#post-102009

    You may find other posts with snippets with this forum search:

    https://support.searchandfilter.com/forums/search/results.php+acf+get_field/

    Lee Wilson
    #212193

    Great support, thanks Trevor, I’ll go through all the info provided and see how I get on.

    I’ll report back here.

    Thanks
    Lee

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

The forum ‘Search & Filter Pro’ is closed to new topics and replies.