WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. bohboh2112
    Member
    Posted 1 year 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' );
    relevanssi_do_query($query);

    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.

    http://wordpress.org/extend/plugins/relevanssi/

  2. Mikko Saari
    Member
    Plugin Author

    Posted 1 year 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
    Member
    Posted 1 year ago #

    Perfect, thanks!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags