WordPress Custom Post Type Index Pageination

I have created a custom post type for my theme called ‘Projects’. On my projects page i am currently displaying all the projects on the one page, using the following code.

$args = array( 'post_type' => 'bw_projects', 'posts_per_page' => 18 );
                    $loop = new WP_Query( $args );
                    while ( $loop->have_posts() ) : $loop->the_post();

                    echo '<div class="project p-project" data-filter="">';
                    echo '<a href="'.get_permalink( $post->ID).'">';  
                    echo '</a>'; 
                    echo '</div>';



I am using archive-projects.php which is using pagination much the same as posts. Code as follows..

    if ( have_posts() ) :

        /* Start the Loop */
        while ( have_posts() ) : the_post();

            get_template_part( 'template-parts/post/contentp', get_post_format() );


    else :

        get_template_part( 'template-parts/post/contentp', 'none' );

        <ul class="pager">
            <li><?php next_posts_link( 'Previous' ); ?></li>
            <li><?php previous_posts_link( 'Next' ); ?></li>

How do i go about creating a paginated projects home page instead of just displaying all available projects. Would i just add to my existing array (example 1) or is there a specific template i should be using for example (home-projects.php) ?

Read more here: WordPress Custom Post Type Index Pageination

Leave a Reply

Your email address will not be published. Required fields are marked *