How can I do numeric pagination?
<?php
$args4 = array('post_type' => 'post', 'showposts' => 99, 'cat' => 23);
$loop4 = new WP_Query($args4);
while ($loop4->have_posts()) : $loop4->the_post();
?>
<article class="cover-image ds s-overlay post type-post status-publish format-status has-post-thumbnail">
<div class="post-thumbnail">
<a href="<?php the_permalink(); ?>">
<img src="<?php the_post_thumbnail_url(); ?>" alt="">
</a>
</div><!-- .post-thumbnail -->
<header class="entry-header">
<?php echo get_avatar(get_the_author_email(), '100'); ?>
<h3 class="entry-title">
<a href="<?php the_permalink(); ?>" rel="bookmark">
<?php the_title(); ?>
</a>
</h3>
<!-- .entry-meta -->
</header>
<!-- .entry-header -->
<div class="entry-content">
<p></p>
</div><!-- .entry-content -->
<div class="entry-meta">
<a href="<?php the_permalink(); ?>" rel="bookmark">
<i class="fa fa-calendar fs-14 color-main"></i>
<time class="entry-date published updated" datetime="2018-09-18T15:15:12+00:00"><?php echo get_the_date(); ?></time>
</a>
</div>
</article><!-- #post-## -->
<?php endwhile;
wp_reset_postdata(); ?>
<nav class="navigation pagination " role="navigation">
</nav>
How can I do numeric pagination?
<?php
$args4 = array('post_type' => 'post', 'showposts' => 99, 'cat' => 23);
$loop4 = new WP_Query($args4);
while ($loop4->have_posts()) : $loop4->the_post();
?>
<article class="cover-image ds s-overlay post type-post status-publish format-status has-post-thumbnail">
<div class="post-thumbnail">
<a href="<?php the_permalink(); ?>">
<img src="<?php the_post_thumbnail_url(); ?>" alt="">
</a>
</div><!-- .post-thumbnail -->
<header class="entry-header">
<?php echo get_avatar(get_the_author_email(), '100'); ?>
<h3 class="entry-title">
<a href="<?php the_permalink(); ?>" rel="bookmark">
<?php the_title(); ?>
</a>
</h3>
<!-- .entry-meta -->
</header>
<!-- .entry-header -->
<div class="entry-content">
<p></p>
</div><!-- .entry-content -->
<div class="entry-meta">
<a href="<?php the_permalink(); ?>" rel="bookmark">
<i class="fa fa-calendar fs-14 color-main"></i>
<time class="entry-date published updated" datetime="2018-09-18T15:15:12+00:00"><?php echo get_the_date(); ?></time>
</a>
</div>
</article><!-- #post-## -->
<?php endwhile;
wp_reset_postdata(); ?>
<nav class="navigation pagination " role="navigation">
</nav>
Share
Improve this question
edited Mar 27, 2020 at 10:27
bueltge
17.1k7 gold badges62 silver badges97 bronze badges
asked Mar 27, 2020 at 9:59
Can Muhammed KELEKCan Muhammed KELEK
31 bronze badge
1
- Welcome to WordPress Deleopment. What have you achieved so far? please show some effort (edit your question and tel others what have your done so far) – WordPress Speed Commented Mar 27, 2020 at 13:42
1 Answer
Reset to default 0There is a lot af possibilities. I use for few years this method :
$all_post = get_posts($args);
$nb_ppp = get_option('posts_per_page');
$nb_post = count($all_post);
$nb_page = ceil($nb_post / $nb_ppp);
$current_page = (!empty(get_query_var('paged'))) ? get_query_var('paged') : 1;
$args['offset'] = ($current_page == 1) ? 0 : (($current_page - 1) * $nb_ppp);
$args['numberposts'] = $nb_ppp;
$current_posts = get_posts($args);
All informations to create pagination : - Number of pages - Current page - Base link url (miss)
I hope you use a taxonomy to liste your posts :
global $wp_query;
$term = $wp_query->queried_object;
$base_link = get_term_link($term);
Or a basic page model :
global $post;
$base_link = get_permalink($post->ID);
You can create a simple loop (for ...).
$link = $base_link.'/page/'.$i;
Enjoy.