非常确定query\\u posts是最糟糕的查询方式。。。
始终使用get\\u帖子,从我不断被告知的内容中获取信息。删除以下数组中未使用的参数。
$args = array(
\'posts_per_page\' => 5000,
\'offset\' => 0,
\'category\' => ,
\'orderby\' => \'post_date\',
\'order\' => \'ASC\',
\'include\' => ,
\'exclude\' => ,
\'meta_key\' => ,
\'meta_value\' => ,
\'post_type\' => \'post\',
\'post_mime_type\' => ,
\'post_parent\' => ,
\'post_status\' => \'publish\',
\'suppress_filters\' => true );
$posts = get_posts($args);
foreach ($posts as $post) :
?><div class="">
<a href="<?php the_permalink();?>">
<?php
echo the_title();
echo the_post_thumbnail(array(360,360));
the_excerpt(\'more text\');
?></a></div>
<?php endforeach; ?>
<?php
类别id为的WP\\U查询方法:
$query = new WP_Query( array( \'category__in\' => array( 2, 6 ), \'order\' => \'ASC\') );
或者像这样更改查询,但我不知道如何添加升序:
add_action( \'pre_get_posts\', \'add_my_custom_post_type\' );
function add_my_custom_post_type( $query ) {
if ( $query->is_main_query() )
$query->set( \'category\', \'A\' );
// $query->set( \'order\', \'ASC\' ); maybe?
return $query;
}