• Resolved musicman847

    (@musicman847)


    Hi – I have a custom tag (custom taxonomy), in addition to the standard WP post tag, that I’d like to be included in the search algorithm. Is there a filter to accomplish this so that if a user’s search contains the text of ‘name of custom tag’ it would include search results with posts that are tagged with that custom tag and possibly weight them higher? Thanks.

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

    (@msaari)

    No filters are required; Relevanssi does this automatically if you include your custom taxonomy in the indexed taxonomies.

    To give extra weight for the taxonomy, you need some extra code. That’s something Relevanssi Premium does more easily; the free version only shows that “post matched a taxonomy term”, but it cannot separate which taxonomy it is. But if this is your only custom taxonomy, then you can do this:

    add_filter( 'relevanssi_match', 'rlv_custom_tag_boost' );
    function rlv_custom_tag_boost( $match ) {
    if ( $match->taxonomy > 0 ) {
    $match->weight *= 10;
    }
    return $match;
    }

    This function will increase the weight of all search terms that match a taxonomy other than category or tag.

    Thread Starter musicman847

    (@musicman847)

    Thank you! Your reply is invaluable. I very much appreciate your support, totally solved my issue.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.