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.

<?php
$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).'">';  
                    the_post_thumbnail();
                    echo '</a>'; 
                    echo '</div>';

                    endwhile;

                ?>

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

    <?php
    if ( have_posts() ) :

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

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

        endwhile;

    else :

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

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

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


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: