Skip to content

Instantly share code, notes, and snippets.

@bugnumber9
Created October 25, 2023 14:25
Show Gist options
  • Select an option

  • Save bugnumber9/46ac9aacbda4f4030d3281c71141c25e to your computer and use it in GitHub Desktop.

Select an option

Save bugnumber9/46ac9aacbda4f4030d3281c71141c25e to your computer and use it in GitHub Desktop.
PoC
function has_class_single_title_container($content) {
return strpos($content, 'class="single-title-container"') !== false;
}
function replace_text($content){
if (is_single() && has_class_single_title_container($content)) {
$content = preg_replace_callback('/<h2(.*?)class="entry-title"(.*?)>(.*?)<\/h2>/', function($matches) {
return '<h1' . $matches[1] . 'class="entry-title"' . $matches[2] . '>' . $matches[3] . '</h1>';
}, $content);
}
return $content;
}
add_filter('the_content', 'replace_text');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment