Share this Article !

wordpress pagination

wordpress pagination

Displays a paginated navigation to next/previous set of posts, when applicable.

Displays pagination with additional page links

<?php the_posts_pagination( array( 'mid_size' => 2 ) ); ?>

Displays pagination with alternative prev/next text

<?php
the_posts_pagination( array( 
'format' => 'page/%#%/', 
'mid_size' => 2,
 'prev_text' => __( '<span class="icon-left"></span>', 'textdomain' ), //set your back icon
'next_text' => __( '<span class="icon-next"></span>', 'textdomain' ), ) );//set your next icon
?>

in Query set $paged = (get_query_var('page')) ? get_query_var('page') : 1;

  • Add 'paged'=>$paged to paginate all page.
  • Set post per page 'posts_per_page' => 12,

Check Example as below:

<div class="row">
<?php
$paged = (get_query_var('page')) ? get_query_var('page') : 1;
$query = array(
'posts_per_page' => 12,
'order' => 'DESC' ,
'paged'=>$paged
);
query_posts($query);
if (have_posts()) : while (have_posts()) : the_post();?>
<div class="col-lg-3 col-md-3 mb-4">
<div class="h-100">
<a href="<?php the_permalink(); ?>" >
<div class="img-container" data-aos="fade-up">
<?php getthumbnail();?>
</div>
<div class="card-body" >
<?php
catname();
?>
<a href="<?php the_permalink(); ?>" >
<div class="card-title" data-aos="fade-down">
<?php the_title();?>
</div>
</a>
<div class="card-description" data-aos="fade-down">
<?php the_excerpt();?>
</div>
</div>

</a>
</div>
</div>
<?php
endwhile;
the_posts_pagination( array(
'format' => 'page/%#%/',
'mid_size' => 2,
'prev_text' => __( '<span class="icon-left"></span>', 'textdomain' ),
'next_text' => __( '<span class="icon-next"></span>', 'textdomain' ),
) );
?>
<?php endif; ?>
</div>

[:kh]បង្ហាញការញែកជាទំព័របន្ទាប់និងត្រទ្បប់ក្រោយនៃការPostដោយបង្ហាញជាមួយតំណភ្ជាប់ទំព័រ។

<?php the_posts_pagination( array( 'mid_size' => 2 ) ); ?>

បង្ហាញការញែកជាទំព័របន្ទាប់និងត្រទ្បប់ក្រោយនៃការPost

<?php
the_posts_pagination( array( 
'format' => 'page/%#%/', 
'mid_size' => 2,
 'prev_text' => __( '<span class="icon-left"></span>', 'textdomain' ), //set your back icon
'next_text' => __( '<span class="icon-next"></span>', 'textdomain' ), ) );//set your next icon
?>

in Query set $paged = (get_query_var('page')) ? get_query_var('page') : 1;

  • Add 'paged'=>$paged to paginate all page.
  • Set post per page 'posts_per_page' => 12,

ឧទាហរណ៍ដូចខាងក្រោម៖

<div class="row">
<?php
$paged = (get_query_var('page')) ? get_query_var('page') : 1;
$query = array(
'posts_per_page' => 12,
'order' => 'DESC' ,
'paged'=>$paged
);
query_posts($query);
if (have_posts()) : while (have_posts()) : the_post();?>
<div class="col-lg-3 col-md-3 mb-4">
<div class="h-100">
<a href="<?php the_permalink(); ?>" >
<div class="img-container" data-aos="fade-up">
<?php getthumbnail();?>
</div>
<div class="card-body" >
<?php
catname();
?>
<a href="<?php the_permalink(); ?>" >
<div class="card-title" data-aos="fade-down">
<?php the_title();?>
</div>
</a>
<div class="card-description" data-aos="fade-down">
<?php the_excerpt();?>
</div>
</div>

</a>
</div>
</div>
<?php
endwhile;
the_posts_pagination( array(
'format' => 'page/%#%/',
'mid_size' => 2,
'prev_text' => __( '<span class="icon-left"></span>', 'textdomain' ),
'next_text' => __( '<span class="icon-next"></span>', 'textdomain' ),
) );
?>
<?php endif; ?>
</div>

Share this Article !


You may like this
Top 10 most popular programming language in 2025

Top 10 most popular programming language in 2025

Nowadays, we know and see coding skills hold immense value in technology beyond 1990 till 2025, with effects on career advancement being profound. Extremely popular languages such as Python, JavaScript, and Java...
how to improve seo and increase audience for your website

how to improve seo and increase audience for your website

To increase your audience and boost your SEO (Search Engine Optimization), you’ll need to implement a mix of technical strategies, content creation, and marketing campaigns. This is a step-by-step guide to help...
Moodle – how get total course completed and login chart in current year into dashboard page

Moodle – how get total course completed and login chart in current year into dashboard page

To add the total course completed and login chart in the current year to the dashboard, you need to get a query from course complete and login from the database. We created...
(100% worked) How to fix PHP is not recognized as an internal or external command for Xampp Or Wamp

(100% worked) How to fix PHP is not recognized as an internal or external command for Xampp Or Wamp

5 steps for fixing PHP is not recognized as an internal or external command for Xampp rr Wamp. You can follow the tips below. Go to My Computer->properties -> Advanced system setting->...
How to loop post under category in wordpress

How to loop post under category in wordpress

To loop posts under categories, you should know something. get_categories($args): Arguments to retrieve categories and we want to return array List of category objects that   ‘parent’ => 0 .  $categories =...
boostrap columns left in desktop and right in mobile

boostrap columns left in desktop and right in mobile

When you want to change columns left on desktop and right on mobile, we always think about the responsive screen.This tip will help you. following the below code : <div class="container">  ...