//add_content_before_h2
function add_content_before_h2($content){
if (is_single()) {
$div = 'content before h2';
$content = preg_replace('/(<h2>[^<]+)/', $div.'\1', $content);
}
return $content;
}
add_filter('the_content', 'add_content_before_h2');
function add_content_after_h2($content){
if (is_single()) {
$div = 'content after h2';
$content = preg_replace('/(<\/h2>)/i', '\1'.$div, $content);
}
return $content;
}
add_filter('the_content', 'add_content_after_h2');
function add_content_before_h2($content){
if (is_single()) {
$div = 'content before h2';
$content = preg_replace('/(<h2>[^<]+)/', $div.'\1', $content);
}
return $content;
}
add_filter('the_content', 'add_content_before_h2');
function add_content_after_h2($content){
if (is_single()) {
$div = 'content after h2';
$content = preg_replace('/(<\/h2>)/i', '\1'.$div, $content);
}
return $content;
}
add_filter('the_content', 'add_content_after_h2');
Комментариев нет:
Отправить комментарий