Wordpress在渲染之前解析wp_posts.post_content?

Joh*_*ohn 2 wordpress

我注意到,当我把从我的wordpress模板the_post()或the_content()函数,它会自动分析数据库的数据替换新品系<br/>,包装与文本<p>标签等等......有可能是某种"格式"功能在the_post()或the_content()中.

我写了一个查询来直接从wp_posts获取帖子.然后我打印出来就像

<?php
$results = $wp->get_results($sql)
foreach($results as $row) echo $row->post_content; ?>
Run Code Online (Sandbox Code Playgroud)

显然,wordpress'"format"函数不会解析这些数据.什么是输出有道这个内容,使得它经历相同的"格式"功能the_post()或the_content()?

The*_*dic 9

@dpelletier是对的,你可以简单地将该函数应用于$row->post_content字符串.

如果你想让WordPress做通常会对内容做的一切,包括wpautop解析短代码,请使用;

$content = apply_filters('the_content', $row->post_content);
Run Code Online (Sandbox Code Playgroud)