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

Changing the number of search results displayed

A standard way to change the number of search results displayed is something like this: $myquery = “&posts_per_page=5”; $myquery = $query_string.$myquery; query_posts( $myquery ); Unfortunately, this breaks Relevanssi. Relevanssi hasn’t played nice with posts_per_page in any case, for some reason I don’t really understand — this is legacy code from…

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