Forums › Forums › Search & Filter Pro › Custome query
- This topic has 2 replies, 2 voices, and was last updated 5 years, 5 months ago by Anonymous.
-
Anonymous(Private) May 22, 2019 at 4:50 pm #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(Private) May 23, 2019 at 6:48 am #212123I 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:
You may find other posts with snippets with this forum search:
https://support.searchandfilter.com/forums/search/results.php+acf+get_field/
-
AuthorPosts