0

I want to group by posts by months. Like this:

January 2014
Post name
Post name

December 2013
Post name

November 2013
Post name
Post name
Post name
Post name

I need to have 10 months per page, each month can have any number of posts.

I use WordPress kriesi pagination to add pagination into the website.

1 Answer 1

0

Try this code

                                            <?php

                                        $catnam = '1';

                                        $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
                                        // the total of registers to show on each page
                                        $showp = 4;

                                        wp_get_archives("type=monthly&showposts=$showp&paged=$paged");     


                                        while (have_posts() ) : the_post();?>

                                         <h4><a href="<?php echo get_permalink(); ?>"><?php the_title();?></a></h4>

                                         <?php endwhile;?>

                                         <?php
                                            global $wp_rewrite;
                                            $paginate_base = get_pagenum_link(1);
                                            if (strpos($paginate_base, '?') || ! $wp_rewrite->using_permalinks()) {
                                                $paginate_format = '';
                                                $paginate_base = add_query_arg('paged', '%#%');
                                            } else {
                                                $paginate_format = (substr($paginate_base, -1 ,1) == '/' ? '' : '/') .
                                                    user_trailingslashit('page/%#%/', 'paged');;
                                                $paginate_base .= '%_%';
                                            }

                                            echo '<div id="pagination">';
                                            echo paginate_links( array(
                                                'base' => $paginate_base,
                                                'format' => $paginate_format,
                                                'total' => $wp_query->max_num_pages,
                                                'mid_size' => 10,
                                                'current' => ($paged ? $paged : 1),
                                                'type' => '',
                                                'prev_text' => __('<p class="readmore">&laquo; Previous</p>', 'default'),
                                                'next_text' => __('<p class="readmore">Next &raquo;</p>', 'default'),
                                            ));
                                            echo "</div>";
                                        ?>                
1
  • You should always back your answer with good amount of explanation. That is a good practice here in this community :) Feb 9, 2014 at 7:35

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.