wordpress the_content在循环外解析

时间:2012-09-06 17:57:41

标签: wordpress parsing function

the_content()函数以这样的方式解析数据库中的文本,例如段落将围绕它们获得<p>标记。但是,当您在循环外部检索内容时,无法使用the_content()。我目前正在使用$db_object->post_content。但是,通过这种方式,文本不会像the_content()那样被解析,因此添加<p>。只是给出了纯文本。

PHP中是否有函数,或者是否有人知道等同函数以the_content()的方式解析文本并在文本周围输出正确的标记。

Thnx提前。

1 个答案:

答案 0 :(得分:12)

是。使用

$content = $db_object->post_content;
$content = apply_filters( 'the_content', $content );
相关问题