Custom post type archive pagination with HTML5Blank theme?

Can't get the pagination to work. Here's my archive-work.php:

?php get_header(); ?

    main role="main"
        !-- section --
        section

            h1?php _e( 'Work', 'html5blank' ); ?/h1

            ?php get_template_part('loop', 'work'); ?

            ?php get_template_part('pagination'); ?

        /section
        !-- /section --
    /main

?php get_sidebar(); ?

?php get_footer(); ?

loop-work.php:

?php

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

$work = array(
    'post_type' = 'work'
    ,'numberposts' = -1
    ,'posts_per_page' = 2
    ,'paged' = $paged
);

$loop = new WP_Query( $work );

if ($loop-have_posts()): while ($loop-have_posts()) : $loop-the_post(); ?

    !-- article --
    article id="post-?php the_ID(); ?" ?php post_class(); ?

        !-- post thumbnail --
        ?php if ( has_post_thumbnail()) : // Check if thumbnail exists ?
            div class="thumbnail"
                a href="?php the_permalink(); ?" title="?php the_title(); ?"
                    ?php the_post_thumbnail(array(300,225)); // Declare pixel size you need inside the array ?
                /a
            /div
        ?php endif; ?
        !-- /post thumbnail --

        header
            !-- post title --
            h2 class="title"
                a href="?php the_permalink(); ?" title="?php the_title(); ?"?php the_title(); ?/a
            /h2
            !-- /post title --
            span class="date"?php the_time('F Y'); ?/span
        /header

        br/br/

        !-- post details --
        !--span class="author"?php _e( 'Published by', 'html5blank' ); ? ?php the_author_posts_link(); ?/span--
        !--span class="comments"?php if (comments_open( get_the_ID() ) ) comments_popup_link( __( 'Leave your thoughts', 'html5blank' ), __( '1 Comment', 'html5blank' ), __( '% Comments', 'html5blank' )); ?/span--
        !-- /post details --

        ?php html5wp_excerpt('html5wp_index'); // Build your custom callback length in functions.php ?

        ?php edit_post_link(); ?

    /article
    !-- /article --

?php endwhile; ?

?php else: ?

    !-- article --
    article
        h2?php _e( 'Sorry, nothing to display.', 'html5blank' ); ?/h2
    /article
    !-- /article --

?php endif; ?

If I set the default page to 2, it does show the 3rd and 4th entries... so why won't the links show? That's how it's set up in the theme's default archive/loop.

For your reference: https://github.com/toddmotto/html5blank

Thanks.

Topic loop pagination custom-post-types Wordpress

Category Web


Most pagination relies on the $wp_query global. Try changing $loop to $wp_query

And put this wp_reset_postdata(); after the endwhile.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.