Custom Post Type pagination issue in author template

Hi, Guys!

Can anyone help me on this, I’ve been struggling with this issue. I want to add a custom post type into my author.php page but pagination is not working fine it got 404 page issue. I just want to display all the list from my CPT and make the pagination work. It works fine if you want to display the list of the author using ‘author’ => $curauth->ID, below is my code.

$args = array( 
									'post_type' => 'portfolio', 
									'posts_per_page' => 1,
									'paged' => $paged 
								$wp_query = new WP_Query( $args );  

I also used pre_get_posts in my functions.php but still not working.

Thanks for the help!

So I updated my code.


if ( have_posts() ) : 
   while ( have_posts() ) : the_post(); 
	                       		get_template_part( 'loop', 'portfolio' );


function author_custom_post($query) {
	    if ( !is_admin() && $query->is_author() && $query->is_main_query() ) :
	    	$query->set('post_type', array('portfolio'));
	    	$query->set('post_per_page', 10);
add_action('pre_get_posts', 'author_custom_post');

how do I display all portfolio list that is not only from the author post?
Can anyone help me?


You should try

Thank you very much!