特定のcategory-slug.phpページがあります。
最初のカテゴリ「バナー広告」を1ページに1つの投稿のみで表示し、その下に「注目」カテゴリの1ページに3つの投稿を表示したいと思います。
使用したくない: ** query_posts('posts_per_page = 4'); **
pre_get_posts関数を試しましたが、機能しないようです。
現在、表示されているページあたりの投稿数は、[設定]->[閲覧]で割り当てた数です。
これが私の現在のコードです:
$args1 = array(
'category_name' => 'banner-ads',
'posts_per_page' => 1
);
$the_query = new WP_Query( $args1 );
while ( $the_query->have_posts() ) :
$the_query->the_post();
ar2_render_posts( null, array ( 'type' => 'node' ), true );
endwhile;
wp_reset_postdata();
$args2 = array(
'category_name' => 'featured',
'posts_per_page' => 3
);
$query2 = new WP_Query( $args2 );
while( $query2->have_posts() ):
$query2->next_post();
ar2_render_posts( null, array ( 'type' => 'traditional' ), true );
endwhile;
wp_reset_postdata();