Relevanssi - A Better Search
[resolved] Ignore search term (3 posts)

  1. bohboh2112
    Posted 3 years ago #

    I want to use my custom search page as a browse page, that means i want to have it ignore the search term, and instead just return posts from within a custom post type and grouped by custom taxonomy.

    Is this possible? Everytime i omit the search term, it returns nothing.

    This is what I have so far:

    $search_types = isset($_GET['types']) ? $_GET['types'] : $post_types[0]['type']; // e.g. shoppinglist
    $query->query_vars['s'] = $search_term;
    $query->query_vars['taxonomy'] = 'fruit';
    $query->query_vars['term'] = 'oranges';
    $query->query_vars['posts_per_page'] = 5;
    $query->query_vars['operator'] = 'or';
    $query->query_vars['post_type'] = array($search_types);
    $query->query_vars['paged'] = get_query_var( 'paged' );

    with a $search_term works, without doesnt, how do i get it to just return all 'shoppinglist' post_types which are tagged 'oranges' from the 'fruit' custom taxonomy.


  2. Mikko Saari
    Plugin Author

    Posted 3 years ago #

    Please read this: http://www.relevanssi.com/knowledge-base/using-relevanssi-without-a-search-term/

    WIthout a search term, Relevanssi isn't triggered at all, unless you force it to. Using relevanssi_do_query() doesn't help. You need to have the relevanssi_search_ok function described in the document above.

  3. bohboh2112
    Posted 3 years ago #

    Perfect, thanks!

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Relevanssi - A Better Search
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic