• MYGM

    (@mygm)


    Hi, I am working on a site where I need to allow visitors to filter/sort the search results on the page. So far I have the different post types showing up like it should except the posts that is being displayed are not related to the search query at all. The way I have it setup is with 1 main regular loop and then additional loops for each post type. The loop for the post types are like this – `<?php
    global $post;
    $args=array(
    ‘post_type’ => ‘text’,
    ‘post_status’ => ‘publish’,
    );
    $myposts = get_posts($args);
    foreach( $myposts as $post ) : setup_postdata($post); ?>
    // My divs and Content
    <?php endforeach; ?>
    <?php wp_reset_query(); ?>`

    I would like to know what can I do to make the loop show the correct posts. I’ve already tried adding 's' => get_query_var('s') to the array but all it did was show the same exact posts for every post type.

    Any help would be much appreciated. Thanks

  • The topic ‘How to filter Search Results’ is closed to new replies.