0

hello i trying to do pagination with php and woocommerce and wordpress this is my nav pagination

<div class="nav-links">
<a class="next page-numbers" href='<?php //bbloomer_prev_last_product(); ? >'>
    Anterior página
</a>
<span class='page-numbers current'>
    <span class="meta-nav screen-reader-text">
        Página:
    </span>
    1
</span>
<a class="page-numbers" href='<?php //$next_post_url = get_permalink( get_adjacent_post(false,'',false)->ID ); ?>'>
<span class="meta-nav screen-reader-text">
    Página
</span>
2

<a class="next page-numbers" href='<?php //pagination_frontPage(); ?>'>
  Próxima página
</a>  

i can´t give functionality i take several days, i searched many information but i can´t, i have doing a blog page and there i can do pagination. but in my front page or in my page where i show my category list i can´t do pagination. this is my pagination code in functions.php

remove_action( 'woocommerce_before_shop_loop', 'pagination_frontPage', 30 );

function pagination_frontPage() {

$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
  $query = new WP_Query( array(
  'category_name' => 'su-moto',
 'posts_per_page' => 2,
 'paged' => $paged
));
if ( $query->have_posts() ) :
 // begin loop
while ( $query->have_posts() ) : $query->the_post();
    echo '<h2><a href="<?php the_permalink(); ?>" title="Read"><?php 
the_title(); ?></a></h2><?php the_excerpt(); ?>';
endwhile;
echo '<div class="pagination">';
        echo paginate_links( array(
            'base'         => str_replace( 999999999, '%#%', esc_url( get_pagenum_link( 999999999 ) ) ),
            'total'        => $query->max_num_pages,
            'current'      => max( 1, get_query_var( 'paged' ) ),
            'format'       => '?paged=%#%',
            'show_all'     => false,
            'type'         => 'plain',
            'end_size'     => 2,
            'mid_size'     => 1,
            'prev_next'    => true,
            'prev_text'    => sprintf( '<i></i> %1$s', __( 'Newer Posts', 
 'text-domain' ) ),
            'next_text'    => sprintf( '%1$s <i></i>', __( 'Older Posts', 'text-domain' ) ),
            'add_args'     => false,
            'add_fragment' => '',
        ) );
echo '</div>';
 wp_reset_postdata();
else:
echo '<h2> No hay post que mostrar </h2>';

}

i hope that any people can help me

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.