Forums Forums Search & Filter Pro Cannot filter on custom wp post

Viewing 10 posts - 1 through 10 (of 14 total)
  • Trevor
    #198339

    If you remove the line:

    do_action("search_filter_query_posts", 1513);

    do you get results?

    Anonymous
    #198347

    I do get full set of results, when this line is or is not present.
    The only difference is when the line is present is this statement in SQL wp_posts.ID IN (1284,1495,1503,1504,1505,1506,1508) (and this statement is there if i try filtering anything…

    Trevor
    #198353

    Ah, I see. I misunderstood your initial question. I am sorry for that. At least, I think I understand.

    Showing the word searched for is not so difficult. If you have other filters, then it becomes a little more complex, but I can give you links. The documentation page:

    https://searchandfilter.com/documentation/accessing-search-data/

    This thread might help you:

    https://support.searchandfilter.com/forums/topic/accessing-field-slug-on-search-results/

    โ€ฆ and this search will give similar threads I think:

    https://support.searchandfilter.com/forums/search/sf_current_query+get_array+field+%5Bvalue%5D/

    Anonymous
    #198357

    Well I might have asked wrong way ๐Ÿ™‚

    The thing is the filter as I call it with the shortcode shows up, but if I try to filter results (e.g. I select one region in the dropdown or white a text to the search input and press submit), nothing changes – the result set of $trainers remains unchanged (unfiltered), so as the $GLOBALS[‘wp_query’]->request).

    From your first link you provided, I tried this code:

     $sf_current_query = $searchandfilter->get(1513)->current_query();
        echo '<pre>';
        print_r($sf_current_query->get_array());
        echo '</pre>';

    and got

    array (size=10)
      'paged' => int 1
      'search_filter_id' => int 1513
      'search_filter_override' => boolean false
      'posts_per_page' => int 10
      'post_status' => 
        array (size=1)
          0 => string 'publish' (length=7)
      'meta_query' => 
        array (size=0)
          empty
      'post_type' => string 'trainer' (length=7)
      'is_search' => boolean true
      'is_archive' => boolean true
      'post__in' => 
        array (size=7)
          0 => int 1284
          1 => int 1495
          2 => int 1503
          3 => int 1504
          4 => int 1505
          5 => int 1506
          6 => int 1508

    (notice there is no sign of filtering in the array). This is my main problem.

    Anonymous
    #198359

    It seems the filtering request (for example I write ‘Jane’ to the search input, or select region 1) does not come to the query. I believe I went through the documentation but I am not sure if I am missing something how to link the S&F filter with the WP Query so the filtering would work…

    Trevor
    #198362

    Ah, OK

    Instead of using do_action, you can add the filter to the args. Here is an example:

    $args = array(
        'showposts' => 10,
        'post_type' => 'trainer',
        'search_filter_id' => '1513',
    );

    I assume your form ID is 1513.

    Anonymous
    #198376

    Thanks Trevor. Yes, the form ID is 1513.

    I made a mistake. With or without ‘search_filter_id’ => ‘1513’ or do_action, I receive an empty array.

    (The dump I sent before was another debug from the core of your plugin, sorry for mistake.)

    Trevor
    #198378

    Can you do a test using the shortcode method instead (no coding required)? And see if the filter works correctly?

    Anonymous
    #198390

    I created a new page called Test, inserted

    [searchandfilter id="1513"]
    [searchandfilter id="1513" show="results"]

    then in S&F admin changed Display results method using shortcode and changed result url

    And the filter does not work the very same way as on custom template with custom WP query ๐Ÿ™
    I even tried to deactivate all plugins ๐Ÿ™

    Trevor
    #198392

    It is best to try it without any custom query. This test is to try and see if the search works correctly. The format and style will not be good. The question is whether it gives the correct results.

Viewing 10 posts - 1 through 10 (of 14 total)