FavoriteLoadingAdd to favorites

Firstly you have your while loop to run through all your posts.
And above your while loop you have your args.

You need to add this arg

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
$args['paged'] = $paged;
$args['paged'] = $paged;
$args['paged'] = $paged;

Below is a template to start your while loop

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
$args['post_type'] = 'post';
$query = new WP_Query($args);
while ( $query->have_posts() ) : the_post(); ?>
<?php
$query->the_post();
$post_id = get_the_ID();
?>
<div class="card">
<a href="<?php the_permalink(); ?>" class="card-header text-center">
<?php
the_title();
?>
</a>
<div class="card-body">
<?php
the_content();
?>
</div>
</div>
<?php endwhile; ?>
$args['post_type'] = 'post'; $query = new WP_Query($args); while ( $query->have_posts() ) : the_post(); ?> <?php $query->the_post(); $post_id = get_the_ID(); ?> <div class="card"> <a href="<?php the_permalink(); ?>" class="card-header text-center"> <?php the_title(); ?> </a> <div class="card-body"> <?php the_content(); ?> </div> </div> <?php endwhile; ?>
  $args['post_type'] = 'post';

  $query = new WP_Query($args);

  while ( $query->have_posts() ) : the_post(); ?>
    <?php 
      $query->the_post(); 
      $post_id = get_the_ID();
    ?>
    <div class="card">
      <a href="<?php the_permalink(); ?>" class="card-header text-center">
        <?php
          the_title();
        ?>
      </a>
      <div class="card-body">
        <?php
          the_content();
        ?>  
      </div>
    </div>
<?php endwhile; ?>

Your Args must be before your Query!

Then after your endwhile. Paste this code to display your pagination links

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<div class="pagination">
<?php
echo paginate_links( array(
'base' => str_replace( 999999999, '%#%', esc_url( get_pagenum_link( 999999999 ) ) ),
'total' => $query->max_num_pages,
'current' => max( 1, get_query_var( 'paged' ) ),
'format' => '?paged=%#%',
'show_all' => false,
'type' => 'plain',
'end_size' => 2,
'mid_size' => 1,
'prev_next' => true,
'prev_text' => sprintf( '<i></i> %1$s', __( 'Previous', 'text-domain' ) ),
'next_text' => sprintf( '%1$s <i></i>', __( 'Next', 'text-domain' ) ),
'add_args' => false,
'add_fragment' => '',
) );
?>
</div>
<div class="pagination"> <?php echo paginate_links( array( 'base' => str_replace( 999999999, '%#%', esc_url( get_pagenum_link( 999999999 ) ) ), 'total' => $query->max_num_pages, 'current' => max( 1, get_query_var( 'paged' ) ), 'format' => '?paged=%#%', 'show_all' => false, 'type' => 'plain', 'end_size' => 2, 'mid_size' => 1, 'prev_next' => true, 'prev_text' => sprintf( '<i></i> %1$s', __( 'Previous', 'text-domain' ) ), 'next_text' => sprintf( '%1$s <i></i>', __( 'Next', 'text-domain' ) ), 'add_args' => false, 'add_fragment' => '', ) ); ?> </div>
<div class="pagination">
    <?php 
        echo paginate_links( array(
            'base'         => str_replace( 999999999, '%#%', esc_url( get_pagenum_link( 999999999 ) ) ),
            'total'        => $query->max_num_pages,
            'current'      => max( 1, get_query_var( 'paged' ) ),
            'format'       => '?paged=%#%',
            'show_all'     => false,
            'type'         => 'plain',
            'end_size'     => 2,
            'mid_size'     => 1,
            'prev_next'    => true,
            'prev_text'    => sprintf( '<i></i> %1$s', __( 'Previous', 'text-domain' ) ),
            'next_text'    => sprintf( '%1$s <i></i>', __( 'Next', 'text-domain' ) ),
            'add_args'     => false,
            'add_fragment' => '',
        ) );
    ?>
</div>

 

 

Pin It on Pinterest

Garth Baker
Favorite
Loading
en
af
sq
am
ar
hy
az
eu
be
bn
bs
bg
ca
ceb
ny
zh-CN
zh-TW
co
hr
cs
da
nl
en
eo
et
tl
fi
fr
fy
gl
ka
de
el
gu
ht
ha
haw
iw
hi
hmn
hu
is
ig
id
ga
it
ja
jw
kn
kk
km
ko
ku
ky
lo
la
lv
lt
lb
mk
mg
ms
ml
mt
mi
mr
mn
my
ne
no
ps
fa
pl
pt
pa
ro
ru
sm
gd
sr
st
sn
sd
si
sk
sl
so
es
su
sw
sv
tg
ta
te
th
tr
uk
ur
uz
vi
cy
xh
yi
yo
zu
Share This