Wordpress - the_content 不会返回 p 标签 [英] Wordpress - the_content doens't give p tags back

查看:31
本文介绍了Wordpress - the_content 不会返回 p 标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一段代码将我的所有页面返回到一页(自定义 wordpress 主题).代码运行良好,但我无法输出带有任何 p 标签或格式的页面.

I'm using a piece of code that returns all of my pages on 1 page (custom wordpress theme). The code works perfectly, but I can't manage to output the pages with any p tags or formatting.

$pages = get_pages(); 

foreach ($pages as $page_data) {
    $content = apply_filters('the_content', $page_data->post_content); 
    $title = $page_data->post_title; 
    echo $content; 
}

我了解到您可以使用 get_the_content,但我不知道如何在我的循环中实现它.

I've read that you can use get_the_content, but I don't see how I can implemented this in my loop.

谢谢

G.

推荐答案

尝试使用 wpautop 函数.

Try using wpautop function.

echo wpautop($content);

这篇关于Wordpress - the_content 不会返回 p 标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆