Custom Field Based Weight
-
Hi
We would like to add a custom filed to allow to boost posts in the search results.
A field where we can add a multiplier to boost posts.
There is this snippet:add_filter( 'relevanssi_match', 'custom_field_weights' ); function custom_field_weights( $match ) { $featured = get_post_meta( $match->doc, 'featured', true ); if ( '1' === $featured ) { $match->weight = $match->weight * 2; } else { $match->weight = $match->weight / 2; } return $match; }
Is there a way instead of adding the number 1 to the field to make a multiplier?
Also, in the else statement all other posts are cut half the weight, is that correct? can we leave all other posts as-is?Thank you,
Dan
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Custom Field Based Weight’ is closed to new replies.