Integrating Post Views Counter stats
…in the weight calculations is straightforward. The best tool to use is the relevanssi_results filter hook. It lets us modify the weights of the posts. For each post, we calculate a weight multiplier based on the visitor stats and then multiple the weight of the post with that. I add……= 1; } $relevanssi_pvc_weights[ $post_id ] = $weight; } } return $relevanssi_pvc_weights[ $post_id ] ?? 1; } add_filter( ‘relevanssi_results’, ‘rlv_pvc_weights’ ); function rlv_pvc_weights( $post_weights ) { foreach ( $post_weights as $post_id => $weight ) { $post_weights[ $post_id ] = rlv_pvc_weight( intval( $post_id ) ) * $weight; } return $post_weights; }……$relevanssi_pvc_weights[ $post_stats->id ] = $post_stats->count; } $max_visits = max( $relevanssi_pvc_weights ); $factor = $max_visits / 1000; // This controls the normalization. foreach ( $relevanssi_pvc_weights as $post_id => $visits ) { $weight = $visits / $factor; if ( $weight < 1 ) { $weight = 1; } $relevanssi_pvc_weights[ $post_id ] =…