您在哪里进行代码分析?如果直接在循环内的模板文件中执行,那么应该使用get_the_content()
.
但是,过滤可能更有效the_content()
, 通过the_content
滤器e、 g.英寸functions.php
:
function mytheme_filter_the_content( $content ) {
// add code here to filter the_content
// which is contained in the $content variable,
// then return $content
return $content;
}
add_filter( \'the_content\', \'mytheme_filter_the_content\' );
EDIT
如果出于任何原因,您只想解析
the_content()
, 拉出shorcodes,然后执行它们,使用
do_shortcode()
(
Codex ref). e、 g.:
<?php
$page_content = get_the_content();
$page_shortcodes = array() // ...some array that includes whatever shortcodes you found
foreach ( $page_shortcodes as $page_shortcode ) {
do_shortcode( $page_shortcode );
}
?>