У меня есть веб-сайт WordPress, в каждом сообщении есть редактор wysiwyg. Я загружаю последние сообщения на главной странице, но переносы строк не работают. Но если вы проверите страницу самой новостной статьи. Разрывы строки работают правильно. Хотя обе страницы используют один и тот же HTML. Новостные статьи на главной странице находятся в нижней части страницы.
это код, который зацикливает содержимое на главной странице (странице с проблемой):
$args = [
'post_type' => 'post',
'posts_per_page' => 3,
'orderby' => 'publish_date',
'order' => 'DESC',
];
$context['news'] = Timber::get_posts($args);
foreach($context['news'] as $key => $value){
$context['news'][$key]->post_date = strtotime($context['news'][$key]->post_date);
$context['news'][$key]->post_date = date('Y-m-d', $context['news'][$key]->post_date);
$context['news'][$key]->post_link = get_page_link($context['news'][$key]->ID);
$context['news'][$key]->post_content = substr($context['news'][$key]->post_content, 0, 500) . '...';
}
И это код, который отображает HTML на странице новостей: (который отлично работает):
$args = [
'post_type' => 'post',
'posts_per_page' => -1,
'order' => 'DESC',
];
$context['news'] = Timber::get_posts($args);
foreach($context['news'] as $key => $value){
$context['news'][$key]->post_date = strtotime($context['news'][$key]->post_date);
$context['news'][$key]->post_date = date('Y-m-d', $context['news'][$key]->post_date);
$context['news'][$key]->post_link = get_page_link($context['news'][$key]->ID);
$context['news'][$key]->news_content = get_field('news_content', $context['news'][$key]->ID);
}
Домашняя страница: http://chininimusic.com/
Пример новостной статьи: http://chininimusic.com/verse-ital-100-roots-tour/