0
Good morning, you guys!
I’m having a problem some time to make a pagination with wordpress.
I’m trying to implement a stylized pagination, but I’m having a hard time making it work in a certain way.
function wp_pagination( $query=null, $wpcpn_posts=null )
{
$big = 999999999;
$published_posts = wp_count_posts()->publish;
$posts_per_page = get_option('posts_per_page');
$page_number_max = ceil($published_posts / $posts_per_page);
$paginate = paginate_links(
array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'type' => 'array',
'total' => $page_number_max,
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'prev_text' => __('«'),
'next_text' => __('»'),
)
);
if ( $page_number_max > 1 && $paginate ) {
echo '
<nav aria-label="Navegação da página" id="paginacao">
<ul class="pagination justify-content-center">
';
foreach ( $paginate as $page ) {
echo '<li class="page-item active"><a class="page-link rounded-circle" href="'. $page .'">'. $page .'</a></li>';
}
echo '
</ul>
</nav>
';
}}
$args = array( 'numberposts' => '1' );
$recent_posts = wp_get_recent_posts( $args );
foreach( $recent_posts as $recent ){
<div class="card rounded" id="post-card">
<div class="row">
<a href="<?= get_permalink($recent["ID"]); ?>" class="col-12 col-sm-6"><img src="<?= get_the_post_thumbnail_url($recent["ID"], 'full'); ?>" class="card-img-top" height="232" alt="Imagem de capa do card"></a>
<div class="card-body col-12 col-sm-6">
<p><span><?= (get_the_category()[0]->name); ?></span></p>
<a href="<?= get_permalink($recent["ID"]); ?>"><h5 class="card-title"><?= $recent['post_title']; ?></h5></a>
<!-- Lembrar que a descrição do blog deve terno maximo 153 char-->
<p class="card-text"><?= limitar_caracteres($recent['post_excerpt'], 153); ?></p>
<a href="<?= get_permalink($recent["ID"]); ?>" class="card-text verMais">Ver mais</a>
</div>
</div>
</div>
The result is this:
Could someone give me a hand, please :/
Thank you Daniel!
– Moises Fausto