1

I am trying to show all the posts of a particular category on my home page. There are over 70 posts in that category. I would like have a pagination so that only 10 posts are displayed and have pagination set so users can move to next page by clicking the page nos. Can this be possible? Here is the current code that i have

   global $post;
        $args = array( 'numberposts' => 5, 'offset'=> 0, 'ORDER BY'=>'date', 'order'=>'desc','category' => 1 );
        $myposts = get_posts( $args );
        foreach( $myposts as $post ) :  setup_postdata($post); 
          //  while(have_posts()):the_post();
            $attrs = array(
        'src'   => $src,
        'class' => "",
        'alt'   => get_the_title(),
        'title' => get_the_title(),
    );

Thanks

Prady

1

Have a look at the examples on the Codex for get_posts();

As for pagination, there are many plugins available, this one for example : WP-Paginate

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.