Skip to main contentSkip to footer

Total is a popular theme from WPExplorer. It mostly works fine with Relevanssi, with just one little issue.

Total sets the post_type parameter for all searches to include all public post types. This is fine for most cases, but if you want to include user profiles or taxonomy terms in the search results, Total will block them from appearing in the search results as well.

The solution for this is fortunately simple. Add this to your site:

add_filter(
  'relevanssi_modify_wp_query',
  function( $query ) {
    $query->set( 'post_type', '' );
    return $query;
  }
);

This simply wipes out the post_type parameter, leaving it up to Relevanssi to choose which post types are shown and which are not. If you want to, you can specify the post types you want to include in the parameter. For example to only shows pages and users, you can use:

add_filter(
  'relevanssi_modify_wp_query',
  function( $query ) {
    $query->set( 'post_type', 'page,user' );
    return $query;
  }
);

Thanks to Max Elman.

Your account

Not logged in. Log in to see your license details.

Search

Popular Resources

The search form shortcode

Relevanssi includes a search form shortcode that can be used to display a search form. The shortcode is searchform and it was introduced in Relevanssi Premium 2.0 and Relevanssi 4.0. Adding query parameters This shortcode prints out a basic search form. If you want to add additional query parameters, that’s……return $form; } Add this code to your site. Note this will then apply to all search forms, not just the ones generated by the shortcode. Versions 2.2.4 (Premium) and 4.1.3 (free) added a new filter hook, relevanssi_search_form, which does the same but only applies to the shortcode search form….…easy: just add parameters to the shortcode. Here are some examples: Search for: will restrict the search form to just products. Search for: will restrict the search form to posts, pages and news. Search for: will restrict the search form to categories 10, 14 and 17. Search for: will do…

Polylang attachment searching
If Polylang is in use and you haven’t enabled “Media translation“, your attachment files won’t have a language. That’s fine,…

Related Posts:

Comment Section:

1 Comment. Leave new

  • Hey there!

    This is Aj the developer of the theme and owner of WPExplorer.com. First of all thank you for posting this article. I’ll be sure to add a fix in the upcoming 4.8.3 update. Reading through your docs, it looks as simple as including “user” into the list of post types, which I don’t see any harm doing.

    Feel free to reach out to me in the future if you ever need or want to 😉

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed