• Resolved joeysjoey

    (@joeysjoey)


    I’m trying to severely lower a category’s weight so that any posts associated with that category will show at the end of the results.

    // custom code for relevanssi I added
    add_filter( 'relevanssi_match', 'rlv_boost_one_term' );
    function rlv_boost_one_term( $match ) {
    if ( has_term( 'latest-news', 'category', $match->doc ) ) {
    $match->weight -= 10;
    }
    return $match;
    }

    Here’s the code I attempted using the documentation, but it doesn’t seem to change the search results at all, still all the same. My “weights” are still the default from install, so no changes, I figured removing 10 from this category would have those specific posts drop off, but it doesn’t.

    Any help is appreciated.

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

    (@msaari)

    The relevance scores can be thousands, so subtracting 10 usually means nothing. You can see the scores in the Relevanssi admin search (Dashboard > Admin search); that helps with the adjustments.

    Instead of subtracting 10, try multiplying the weight by 0.001.

    Thread Starter joeysjoey

    (@joeysjoey)

    Awesome, worked, thank you!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Lower a category’s weight’ is closed to new replies.