Hi my WordPress theme not supportimg pagination.How can i add custom pagination in wordpress?

i want to display only 5 posts in my blog page. Is there any way to fix this issue?

Related posts

Leave a Reply

1 comment

  1. Hi nikita pagination is a default property of wordpress.
    Refer WordPress Codex
    So please Remove the query_posts part from the template files (index.php, category.php).

        <?php 
    // query to set the posts per page to 5
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args = array('posts_per_page' => 5, 'paged' => $paged );
    query_posts($args); ?>
    

    And add the query for your home and category pages back in your theme’s functions.php file:

    function my_post_queries( $query ) {
      // do not alter the query on wp-admin pages and only alter it if it's the main query
      if (!is_admin() && $query->is_main_query()){
    
        // alter the query for the home and category pages 
    
        if(is_home()){
          $query->set('posts_per_page', 5);
        }
    
        if(is_category()){
          $query->set('posts_per_page', 5);
        }
    
      }
    }
    add_action( 'pre_get_posts', 'my_post_queries' );
    

    Maybe your problem will solve…