@petersem

Как в recent post carousel сделать ограничение по количеству символов?

В плагине есть функция ограничивающая контент по количеству слов.
content_words_limit : [recent_post_carousel content_words_limit=»30″ ] (Control post short content Words limit. By default limit is 20 words).
Есть ли возможность ограничить контент по количеству символов ?
Нашел в файле wppsac-function.php такую функцию
// Manage content limit
function wprps_limit_words($string, $word_limit)
{
if( !empty($string) ) {
$content = strip_shortcodes( $string ); // Strip shortcodes
$content = wp_trim_words( $string, $word_limit, '...' );
return $content;
}
}
  • Вопрос задан
  • 6 просмотров
Пригласить эксперта
Ответы на вопрос 1
@petersem Автор вопроса
Добавил функцию со страницы
WP post_content лимит по количеству символов, как реализовать?

function the_truncated_post($symbol_amount) {
$filtered = strip_tags( preg_replace('@@si', '', preg_replace('@@si', '', apply_filters('the_content', get_the_content()))) );
echo substr($filtered, 0, strrpos(substr($filtered, 0, $symbol_amount), ' ')) . '...';
}
И заменил wp_trim_words на he_truncated_post и убрал $string,
// Manage content limit
function wprps_limit_words($string, $word_limit)
{
if( !empty($string) ) {
$content = strip_shortcodes( $string ); // Strip shortcodes
$content = the_truncated_post( $word_limit, '...' );
return $content;
}
}
Ответ написан
Комментировать
Ваш ответ на вопрос

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

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