Forums › Forums › Search & Filter Pro › Search and filter Custom post types
Tagged: custom post type
- This topic has 4 replies, 2 voices, and was last updated 8 years, 8 months ago by
Anonymous.
-
Anonymous(Private) September 22, 2016 at 2:31 pm #59549
Hello,
I was hoping someone could explain me what would be the best way to use Search and filter in combination with a Custom Post Type. I created a custom post type ‘products’. To show them I’ve created a page ‘page-products.php’ with this loop:
<?php echo do_shortcode( '[searchandfilter id="39"]' );?> <?php $loop = new WP_Query( array( 'post_type' => 'products', 'posts_per_page' => -1 ) ); ?> <?php while ( $loop->have_posts() ) : $loop->the_post(); ?> <?php the_title( '<h3>', '</h3>' ); ?> <?php endwhile; wp_reset_query(); ?>
At the top of the page I put the shortcode for Search and Filter.
This works, but I think there is a better way to set this up. Again, I hope someone can help me out.
Thanks you,
Martijn.Trevor(Private) September 23, 2016 at 8:54 am #59685Hi Martijn
I am not quite sure what it is you are asking. I am unable to offer you coding advice about how to create theme templates, whether you are writing your own theme or whether you are modifying an existing theme. In our plugin folder you will find a templates folder and in that a results.php file that our plugin uses by default for a form that is set to use the ‘Shortcode’ display results method. Would that help?
Otherwise, do a search of this forum for
have_posts
and see the advice given to others (such as this post) and what others have used. -
AuthorPosts