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

Translation and multilingual plugins
Different translation plugins use different methods for storing the translations, and these methods have varying compatibility with how Relevanssi works…
Click tracking

…$output ) { return $output; } $popular_posts = $wpdb->get_results( “SELECT post_id, count(*) AS hits FROM {$relevanssi_variables[‘tracking_table’]} GROUP BY post_id ORDER BY hits DESC LIMIT 6” ); $post_ids = wp_list_pluck( $popular_posts, ‘post_id’ ); $links = array(); foreach ( $post_ids as $id ) { $links[] = ‘<a href=”‘ . get_the_permalink( $id )……This helps prevent users from distributing the URLs with the click tracking parameters. Showing the most clicked pages I’m using this function to create a shortcode that will display the most popular articles: add_shortcode( ‘most_clicked_results’, ‘most_clicked_results_shortcode’ ); function most_clicked_results_shortcode() { global $relevanssi_variables, $wpdb; $output = get_transient( ‘most_clicked_results_shortcode’ ); if (……. ‘”>’ . get_the_title( $id ) . ‘</a>’; } $links = implode( ‘ | ‘, $links ); $output = ‘<p class=”most_clicked_results_shortcode”>Most popular search results: ‘ . $links . ‘</p>’; set_transient( ‘most_clicked_results_shortcode’, $output, WEEK_IN_SECONDS ); return $output; } The [most_clicked_results] shortcode fetches the six most clicked posts and creates a simple…

Flatsome

…wc_get_page_id( $wc_page_type ) ) { $wc_page = true; } } } if ( ! $wc_page ) { array_push( $pages, $post->ID ); } } do_action( ‘flatsome_products_page_loader’ ); if ( ! empty( $posts ) || ! empty( $pages ) ) { $list_type = get_theme_mod( ‘search_result_style’, ‘slider’ ); if ( ! empty( $posts…Posts and pages on the product search results The Flatsome theme, when combined with WooCommerce, has a product search results page that can also show posts and pages. That doesn’t work with Relevanssi out of the box, but fortunately can be made to work. The function that adds the functionality……! empty( $flatsome_live_search_query ) ) { $variations = rlv_get_variation_ids( $post->ID ); if ( isset( $variations[ $flatsome_live_search_query ] ) ) { remove_filter( ‘post_type_link’, ‘rlv_wc_variation_permalink’, 10 ); return get_permalink( $variations[ $flatsome_live_search_query ] ); } } return $permalink; } function rlv_get_variation_ids( $product_id ) { $variation_ids = array(); $args = array( ‘post_parent’ => $product_id,

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