query_posts()

最后更新于:2021-11-27 20:50:10

query_posts( array|string$query)

Sets up The Loop with query parameters.

参数

$query

(array|string) (Required) Array or string of GC_Query arguments.

响应

(GC_Post[]|int[]) Array of post objects or post IDs.

// The Query
query_posts( $args );

// The Loop
while ( have_posts() ) : the_post();
	echo '
<li>';
	the_title();
	echo '</li>

';
endwhile;

// Reset Query
gc_reset_query();

源文件

文件: gc-includes/query.php

function query_posts( $query ) {
	$GLOBALS['gc_query'] = new GC_Query();
	return $GLOBALS['gc_query']->query( $query );
}