WordPress.org

Support

Support » How-To and Troubleshooting » Problem with Pagination for Custom Post Types

Problem with Pagination for Custom Post Types

  • I have seen many had problems with pagination for Custom Post Types and most of them have successfully solved their issue. I still have no luck in that.

    Here is my problem.

    I’m using Custom Post Type UI for creating Custom Post types ( for example one of the post types that I’ve created is articles ).
    For listing them I have created Page Template articles.php and the slug that I’m using for that page is article ( for example the page where I have created is listed here http://esotericquotes.com/article/ ).

    The first page is listing fine, but when I go to the next page it redirect to the first page and gives the permalink of the second page http://esotericquotes.com/article/page/2/

    I’m using Maxx – Responsive Creative WordPress Theme and the code for the pagination for this theme looks like this:

    /*Custom Pagination
    /*---------------------------------------------------------------------------------------------*/
    if ( ! function_exists( 'md_pagi_nav' ) ) :
    	function md_pagi_nav(array $query = array()) {
    	?>
    	<div class="m-pagination">
    			<?php
                    global $wp_query;
    
                    $big = 999999999; 
    
                    echo paginate_links( array(
                        'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
                        'format' => '?paged=%#%',
                        'current' => max( 1, get_query_var('paged') ),
                        'total' => $wp_query->max_num_pages,
                        'next_text'    => __('Next &rarr;','framework'),
                        'prev_text'    => __('&larr; Prev','framework')
                    ) );
                ?>
                <span class="pagination-meta">
                    <?php
                        //display Page x of y pages
                        $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
                        echo 'Page ' . $paged . ' of ' . $wp_query->max_num_pages ;
    
                    ?>
                </span>
    
            </div>
    
            <?php
    	}
    endif;

    Can someone with more experience in coding help me how to solve this issue please?

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Problem with Pagination for Custom Post Types’ is closed to new replies.