Forums Forums Search & Filter Pro Custom Post Types with Search & Filter Pro

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

    Hi Ross,

    I have two separate pages that are each running a separate Filtering system. On one (Blog), I am looping through all of my Posts and the filtering system is working well. On the other (Thoughts), I am looping through a Custom Post Type:

    <?php $args = array( 'post_type' => 'thoughts');
    	$loop = new WP_Query( $args );
    	while ( $loop->have_posts() ) : $loop->the_post(); ?>
        <?php get_template_part( 'thought', 'search' ); ?>
    <?php endwhile; ?>

    and the filtering system does not return anything.

    Oddly, if I change the Thoughts page template so that it loops through all Posts, regardless of post type

    <?php while ( have_posts() ) : the_post(); ?>
    	<?php get_template_part( 'content', 'search' ); ?>
    <?php endwhile; ?>

    then the filtering system works properly.

    Does Search & Filter Pro only work with a normal WordPress loop, or is there something behind the scenes that I can add/change to solve this issue?

    Best,
    Alex

    Anonymous
    #10282

    Just saw your answer to “Search result filtering”, and the fact that there cannot be WP_Query in my loop. Is there a way around this, so that I can display only my custom post type initially, and then also use Search & Filter Pro?

    Ross Moderator
    #10283

    Hey Alex

    S&F uses the loop – it doesn’t mean you can’t use other queries but you must allow for the loop to proceed normally…

    Usually you must reset the query – see the codex for nested queries and how to reset –

    http://codex.wordpress.org/Function_Reference/wp_reset_postdata

    🙂

    Ross Moderator
    #10284

    PS the alternative is to use a shortcode for results – which you can place anywhere – but you must be confident with html/css to style the results yourself 🙂

    Anonymous
    #10285

    A-ha, thanks for the info! I ended up hiding .type-posts in my CSS as a temporary solution (ick) so I’ll take a look at your suggestion instead! Thank you, as always!

    All the best,
    Alex

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