one4zero
@one4zero

Как правильно написать код чтобы убрать ошибку?

Столкнулся с проблемой, как правильно написать код ниже, чтобы убрать ошибку?

/* после тега more */
function aftermore2($content) {
$ads = if(function_exists('the_ratings')) { the_ratings(); }
$content=preg_replace('#<span.*?id="more-(.*?)".*?></span>#','<span id="more-\1"></span><center>'.$ads.'</center>',$content);
return $content;
}
add_filter('the_content', 'aftermoreads');


ff96e389d69289a4781592d2b455a53c11e3381b
  • Вопрос задан
  • 191 просмотр
Решения вопроса 1
politon
@politon
HTML5,CSS3,JS,PHP,SQL,API,canvas,animation...
$ads = убрать
<?php
function aftermore2($content) {
if(function_exists('the_ratings')) { the_ratings(); }
$content=preg_replace('#<span.*?id="more-(.*?)".*?></span>#','<span id="more-\1"></span><center>'.$ads.'</center>',$content);
return $content;
}
add_filter('the_content', 'aftermoreads');
Ответ написан
Пригласить эксперта
Ответы на вопрос 1
@alex159
function aftermore2($content) {
$ads = (function_exists('the_ratings')) ?  the_ratings();
$content=preg_replace('#<span.*?id="more-(.*?)".*?></span>#','<span id="more-\1"></span><center>'.$ads.'</center>',$content);
return $content;
}
add_filter('the_content', 'aftermoreads');
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы