function interlink_h6_cleanup_existing_links() {
$args = [
'post_type' => get_post_types(['public' => true]),
'posts_per_page' => -1,
'post_status' => 'publish',
];
$posts = get_posts($args);
foreach ($posts as $post) {
$content = $post->post_content;
$new_content = preg_replace('/
Related posts about(.*?)<\/h4>\s*((.*?)<\/h6>\s*)+/i', '', $content);
if ($new_content !== $content) {
wp_update_post([
'ID' => $post->ID,
'post_content' => $new_content
]);
error_log("H6 nettoyés dans post ID {$post->ID}");
}
}
}
Kirk Franklin jamaica - BGospel.com EN
Tag: Kirk Franklin jamaica