Pagination don’t list all entries on Index.php
Question
Pagination works perfect on pages but not on the Index.php
Problem: It doesn’t list all entries and the Count for Entries beyond settings >> reading interferes. Depending from what I setting the Count, Entries missing or it list too much empty pages in the Pagination-list at the end…
This is what I did:
if ( get_query_var( 'paged' ) ) { $paged = get_query_var( 'paged' ); }
elseif ( get_query_var( 'page' ) ) { $paged = get_query_var( 'page' ); }
else { $paged = 1; }
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$args = array(
'posts_per_page' => 4 ,
'category_name'=> 'Allgemein',
'post_status' => 'publish, future',
'order'=> 'DEC',
'orderby'=> 'date',
'paged'=> $paged
);
$the_query = new WP_Query( $args );
$myposts = get_posts( $args );
foreach ($myposts as $post) : setup_postdata($post);?>
<?php the_content(); ?> <?php endforeach; ?>
<div><?php the_posts_pagination( array(
'mid_size' => 4,
'prev_text' => __( '←', 'textdomain' ),
'next_text' => __( '→', 'textdomain' ),
) ); ?></div>```
Thanks for any help & solution
PS: The post_status future will be shown by using a function “show_future_posts”, as I want to have a special Entry always first.
0
10 months
2022-08-15T19:50:40-05:00
2022-08-15T19:50:40-05:00 0 Answers
0 views
0
Leave an answer