Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Mikko Saari

    (@msaari)

    Those instructions are for custom fields and only for Relevanssi Premium. You’re working with a taxonomy term here, not a custom field.

    See “Weight from taxonomy terms” here: https://www.relevanssi.com/knowledge-base/relevanssi-match/

    This is what you’re looking for:

    add_filter( 'relevanssi_match', 'rlv_boost_one_term' );
    function rlv_boost_one_term( $match ) {
    	if ( has_term( 'Animal House', 'pa_producer', $match->doc ) ) {
    		$match->weight = $match->weight * 5000;
    	}
    	return $match;
    }

    Something like that.

    • This reply was modified 4 years, 7 months ago by Mikko Saari.
    Thread Starter Daryl Sirota

    (@fastfngrz)

    Awesome, fixed my admin search weighting scores just as expected… Now the problem is my search results page still don’t reflect the new weights. I expect I’ve got something overriding the search.php. Looked for the issues you mention in your “90% fix” post, but can’t find anything.

    Is there a good way to track down what PHP files are actually returning the search results? This is my search.php from StoreFront if it helps.

    <?php
    /**
    * The template for displaying search results pages.
    *
    * @package storefront
    */

    get_header(); ?>

    <div id=”primary” class=”content-area”>
    <main id=”main” class=”site-main” role=”main”>

    <?php if ( have_posts() ) : ?>

    <header class=”page-header”>
    <h1 class=”page-title”>
    <?php
    /* translators: %s: search term */
    printf( esc_attr__( ‘Search Results for: %s’, ‘storefront’ ), ‘<span>’ . get_search_query() . ‘</span>’ );
    ?>
    </h1>
    </header><!– .page-header –>

    <?php
    get_template_part( ‘loop’ );

    else :

    get_template_part( ‘content’, ‘none’ );

    endif;
    ?>

    </main><!– #main –>
    </div><!– #primary –>

    <?php
    do_action( ‘storefront_sidebar’ );
    get_footer();

    Plugin Author Mikko Saari

    (@msaari)

    The Storefront template is very basic and works well with Relevanssi. The problem is something else. Try disabling other plugins, perhaps there’s a conflict with another plugin.

    Thread Starter Daryl Sirota

    (@fastfngrz)

    And (as expected) you’re right! I have a “snippets” plugin that allows us to add custom code, and there was the conflict.

    Problem solved, thanks for your quick and accurate help!

    Thread Starter Daryl Sirota

    (@fastfngrz)

    Resolved.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Boosting the weight of product attributes’ is closed to new replies.