Forums Forums Search & Filter Pro Search and filter Custom post types

Viewing 5 posts - 1 through 5 (of 5 total)
  • Anonymous
    #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
    #59685

    Hi 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.

    Anonymous
    #59697

    I understand. And this helps already 🙂
    Thanks!

    Trevor
    #59706

    Let me know if I can close this thread or help you further?

    Anonymous
    #59718

    You can close. Thanks!

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