Created
February 10, 2022 06:23
-
-
Save msaari/7fcc25bf0b2a3ec858f641fa02e635dc to your computer and use it in GitHub Desktop.
Increases the weight for headings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'relevanssi_post_content', 'rlv_heading_boost' ); | |
function rlv_heading_boost( $content ) { | |
if ( preg_match_all( '/<h1.*?>(.*?)<\/h1>/', $content, $h1_headings ) ) { | |
foreach ( $h1_headings[1] as $heading ) { | |
$content .= " $heading $heading $heading $heading $heading $heading $heading $heading"; | |
} | |
} | |
if ( preg_match_all( '/<h2.*?>(.*?)<\/h2>/', $content, $h2_headings ) ) { | |
foreach ( $h2_headings[1] as $heading ) { | |
$content .= " $heading $heading $heading $heading"; | |
} | |
} | |
if ( preg_match_all( '/<h3.*?>(.*?)<\/h3>/', $content, $h3_headings ) ) { | |
foreach ( $h3_headings[1] as $heading ) { | |
$content .= " $heading $heading"; | |
} | |
} | |
return $content; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment