皆さんが私を助けてくれることを願っています。
1 つのカテゴリから 2 つの非常に単純なカスタム ループがあります。1 つはスティッキー、もう 1 つは非スティッキーです。スティッキー投稿を最初のページにのみ表示し、ページネーション時に残りのページには表示しないようにします。また、各ページに正確に 8 件の投稿 (1 ページ目のスティッキー投稿を含む) が必要です。これはすべて、以下のコードで正常に機能しています。
問題はこれです: ページ 1: 1 スティッキー & 投稿 #15-9 ,ページ 2: 投稿 # 7 -1. スティッキー ポストのため、WP は 2 ページ目の 1 つのポスト (#8) をスキップします。誰でもこれに対する解決策を得ましたか?大変助かりました。
<!-- Sticky -->
<?php if ( $paged != True ): ?>
<?php $wp_query = new WP_Query(array('post__in' => get_option('sticky_posts'), 'category_name' => Work)); ?>
<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
<?php get_template_part( 'loop', 'index' ); ?>
<?php endwhile; ?>
<?php wp_reset_postdata(); // reset the query ?>
<?php endif ?>
<?php
$postcount = $wp_query->post_count;
$postnumber = 8;
if ( $paged != True ){ $postnumber = $postnumber - $postcount; }
?>
<!-- Non-Sticky -->
<?php $wp_query = new WP_Query(array('post__not_in' => get_option('sticky_posts'), 'category_name' => Work, 'posts_per_page' => $postnumber, 'paged' => $paged)); ?>
<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
<?php get_template_part( 'loop', 'index' ); ?>
<?php endwhile; ?>
<?php wp_reset_postdata(); // reset the query ?>