我有一个wordpress网站,每个帖子都有一个所见即所得的编辑器。我在首页上加载了最新帖子,但换行符无效。但是,如果您查看新闻文章页面本身。换行符工作正常。即使两个页面使用相同的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/