函数原型
class WP_Query {}
函数描述
The WordPress Query class.
是否弃用
未弃用
函数参数
无
函数返回值
无
函数位置
File: wp-includes/class-wp-query.php.
函数源码
<?php
// The Query
$the_query = new WP_Query( $args );
// The Loop
if ( $the_query->have_posts() ) {
echo '<ul>';
while ( $the_query->have_posts() ) {
$the_query->the_post();
echo '<li>' . get_the_title() . '</li>';
}
echo '</ul>';
} else {
// no posts found
}
/* Restore original Post Data */
wp_reset_postdata();源码链接
变更日志
| Version | Description |
|---|---|
| 4.5.0 | Removed the $comments_popup property. |
| 1.5.0 | Introduced. |

