Site icon Anthony Carbon

The7 pagination in custom WP_Query

The7 pagination in custom WP_Query, just copy the code below and paste it in your functions.php.

dt_paginator( $query, array( 'class' => 'paginator no-ajax', 'ajaxing' => false ) );


Example:


$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
$args = array( 'cat' => '8', 'posts_per_page' => 8, 'paged' => $paged );
$query = new WP_Query( $args );

if ( $query->have_posts() ) {
	while ( $query->have_posts() ) {
		$query->the_post();
		echo '<h4>' . get_the_title() . '</h4>';
		echo wpautop( get_the_excerpt() );
	}
	wp_reset_postdata();
} else {
	echo "<p>no posts found</p>";
}

dt_paginator( $query, array( 'class' => 'paginator no-ajax', 'ajaxing' => false ) );
Exit mobile version