Home » Ask (Forum) » Manual Set Number of Post in Custom Post Type

Question

Display Number of post in custom post type Archive. Copy paste below code in your function file.

function number_post( $query ) {
	if ( !is_admin() && $query->is_main_query() ) {
		if ( is_post_type_archive( 'book' ) ) {
			$query->set( 'posts_per_page', 8 );
			return;
		}
	}	
}
add_action('pre_get_posts','number_post');

Note:
– ‘Book‘ is you custom post type.
– ‘8‘ is total post per page.

Good luck!

Jul 26, 2016 (4 months ago) - Posted by No Comments

Your Answer

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