In the members-only forum, a user asked:

Hi,
If I wish to use Easy posts for a Custom post type Is it possible to

do Pagination (different from the reading list)
Have a search form
Would really appreciate a tutorial for this

This tutorial provides the steps to set a specific number of posts per page to appear on a portfolio Custom Post Type’s archive page which is different from the number set for archives in general at Settings > Reading > Blog pages show at most.

Step 1

Install and activate Code Snippets plugin.

Step 2

Go to Snippets > Add New.

Title: Set the number of items per page on Portfolio CPT Archive

Code:

add_filter( 'pre_get_posts', 'custom_change_portfolio_posts_per_page' );
/**
 * Change Posts Per Page for Portfolio Archive.
 * 
 * @param object $query data
 *
 */
function custom_change_portfolio_posts_per_page( $query ) {

    if ( $query->is_post_type_archive( 'portfolio' ) && ! is_admin() && $query->is_main_query() ) {
          $query->set( 'posts_per_page', '6' );
    }

    return $query;

}

In the above, replace portfolio with the name of your CPT.

and change 6 to your desired number of posts per page.

Source: https://www.billerickson.net/customize-the-wordpress-query/

Need help implementing a tutorial in your site or want to hire me for custom work?

HIRE ME

Find the article helpful and wish to donate?

DONATE
magnifiercross
>
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram
%d bloggers like this: