better-amp icon indicating copy to clipboard operation
better-amp copied to clipboard

Custom number post in category

Open haianh1991 opened this issue 5 years ago • 0 comments

I want show 100 post in a page of category id 192. But pagination is not working.

this is code in my file archive.php

<?php

better_amp_get_header();

better_amp_enqueue_block_style( 'archive' );

better_amp_template_part( 'views/archive/title' );

better_amp_show_ad_location( 'amp_archive_title_after' );
if (is_category('192')) {
    better_amp_template_part( 'views/loop/list-truyen' );
	better_amp_template_part( 'views/archive/pagination-truyen' );
}
else {
better_amp_template_part( 'views/loop/' . better_amp_page_listing() );

better_amp_template_part( 'views/archive/pagination' );
}


better_amp_get_footer();

this is code in my file list-truyen.php

<?php

better_amp_enqueue_block_style( 'listing', 'css/listing' );
better_amp_enqueue_block_style( 'listing-1', 'css/listing-1' );

?>
<div class="posts-listing posts-listing-1 test-cat-amp-truyen">
<?php
 // The Query
 $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
 $the_query = new WP_Query( array (
 'cat' => 192,
 'posts_per_page' => 100,
 'paged' => $paged,
 'max_num_pages' => 3
 
 ));
  
 if($the_query->have_posts()):
 // The Loop
 while ( $the_query->have_posts() ) : $the_query->the_post();?>
 <article <?php better_amp_post_classes( 'listing-item listing-1-item clearfix' ) ?>>

			<h3 class="post-title">
				<a href="<?php the_permalink() ?>" title="<?php the_title_attribute() ?>">
					<?php the_title() ?>
				</a>
			</h3>

		</article>
		<?php
 endwhile;
 endif;
 ?>
</div>

this is pagination.php

<?php

better_amp_enqueue_block_style( 'pagination' );

if ( is_rtl() ) {
	$prev = '<i class="fa fa-arrow-right" aria-hidden="true"></i>' . better_amp_translation_get( 'prev' );
	$next = better_amp_translation_get( 'next' ) . '<i class="fa fa-arrow-left" aria-hidden="true"></i>';
} else {
	$prev = '<i class="fa fa-arrow-left" aria-hidden="true"></i>' . better_amp_translation_get( 'prev' );
	$next = better_amp_translation_get( 'next' ) . '<i class="fa fa-arrow-right" aria-hidden="true"></i>';
}

the_posts_pagination( array(
	'mid_size'           => 0,
	'prev_text'          => $prev,
	'next_text'          => $next,
	'before_page_number' => '<span class="meta-nav screen-reader-text">' . better_amp_translation_get( 'page' ) . ' ',
	'after_page_number'  => ' ' . sprintf( better_amp_translation_get( 'page_of' ), better_amp_get_query()->max_num_pages ) . ' </span>',
) );

what i can to do custom category page? Thank you for help!

haianh1991 avatar Mar 18 '20 08:03 haianh1991