Skip to Content
PHPCODE
Simple Pagination Post Type
wordpress code / April 14, 2022
$paged = get_query_var(‘paged’) ? get_query_var(‘paged’) : 1;
$args = array(‘post_type’ => ‘post’, ‘posts_per_page’ => 1, ‘paged’ => $paged);
$loop = new WP_Query( $args );
if($loop->have_posts()):
while ( $loop->have_posts() ) : $loop->the_post(); ?>
<a href=”<?php the_permalink(); ?>” class=”file-title” target=”_blank”>
<i class=”fa fa-angle-right” aria-hidden=”true”></i> <?php echo get_the_title(); ?>
</a>
<div class=”file-description”>
<?php the_content(); ?>
</div>
<?php endwhile; wp_reset_postdata();
else:
echo ‘No post Available’;
endif;
?>
<div id=”pagination” class=”clearfix”>
<div><?php next_posts_link( ‘Next posts’, $loop->max_num_pages );?></div>
<div><?php previous_posts_link( ‘Previous posts’ ); ?></div>
</div>
PHPCODE © 2024