2 extra info
source | link

When I display the template page as front page tho the pagination displays correctly tho(with get_query_var('page')). but that's the only way I can get it to work tho.

And as my home I just use index.php

When I display the template page as front page tho the pagination displays correctly tho(with get_query_var('page')). but that's the only way I can get it to work tho.

And as my home I just use index.php

1
source | link

Pagination only working on index page not on a template page

I have a pagination that works perfectly fine on my homepage, the code goes:

    <div class="articles">
        <?php
        $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
        $query = new WP_Query( array( 'post_type' => 'articles', 'orderby'=> 'menu_order', 'posts_per_page' => 5,'paged' => $paged  ) );

        if ( $query->have_posts() ) : ?>
            <?php while ( $query->have_posts() ) : $query->the_post(); ?>
                <div class="article">
                    <div class="entry">
                        <h4 class="title oswald post-title"><?php the_title(); ?></h4>
                        <?php the_content(); ?>
                    </div>
                </div><!--end article-->
                <hr/>
            <?php endwhile; //wp_reset_postdata(); ?>

        <?php else : ?>
            <p>no posts</p>
        <?php endif; ?>

        <?php  if ( function_exists( 'foundationpress_pagination' ) ) { foundationpress_pagination(); } else if ( is_paged() ) { ?>
            <nav id="post-nav">
                <div class="post-previous"><?php next_posts_link( __( '&larr; Older posts', 'foundationpress' ) ); ?></div>
                <div class="post-next"><?php previous_posts_link( __( 'Newer posts &rarr;', 'foundationpress' ) ); ?></div>
            </nav>
        <?php } ?>
    </div>

Here the function of foundationpress_pagination:

function foundationpress_pagination() {
    global $wp_query;

    $big = 999999999; // This needs to be an unlikely integer

    // For more options and info view the docs for paginate_links()
    // http://codex.wordpress.org/Function_Reference/paginate_links
    $paginate_links = paginate_links( array(
        'base' => str_replace( $big, '%#%', html_entity_decode( get_pagenum_link( $big ) ) ),
        'current' => max( 1, get_query_var( 'paged' ) ),
        'total' => $wp_query->max_num_pages,
        'mid_size' => 5,
        'prev_next' => true,
        'prev_text' => __( '&laquo;', 'foundationpress' ),
        'next_text' => __( '&raquo;', 'foundationpress' ),
        'type' => 'list',
    ) );

    $paginate_links = str_replace( "<ul class='page-numbers'>", "<ul class='pagination'>", $paginate_links );
    $paginate_links = str_replace( '<li><span class="page-numbers dots">', "<li><a href='#'>", $paginate_links );
    $paginate_links = str_replace( "<li><span class='page-numbers current'>", "<li class='current'><a href='#'>", $paginate_links );
    $paginate_links = str_replace( '</span>', '</a>', $paginate_links );
    $paginate_links = str_replace( "<li><a href='#'>&hellip;</a></li>", "<li><span class='dots'>&hellip;</span></li>", $paginate_links );
    $paginate_links = preg_replace( '/\s*page-numbers/', '', $paginate_links );

    // Display the pagination if more than one page is found
    if ( $paginate_links ) {
        echo '<div class="pagination-centered">';
        echo $paginate_links;
        echo '</div><!--// end .pagination -->';
    }
}

In my theme I made a page template called 'page-ar.php' and put in Template Name: Article-page in comments on top. I basically copied this whole query and pasted it on this page. However it just shows the first 5 posts correctly and no pagination is shown. Also typing in '/page/2' sends me to the 404 page.

I really have no clue what the problem is I was hoping someone here did. Also I I set the settings>reading to 5 already so I don't think it's that.