Problems with page with post type WordPress

1

I try to paginate the posts of a post type, and I copied the code from another website where I used it but for some reason that I can not understand, I can not get it to work.

I do not get the texts of the next and previous buttons. And when you hit any button it does not do anything

<?php
  $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;

  $args = array(
    'post_type' => 'libros',
    'posts_per_page' => 4,
    'orderby' => 'title',
    'order' => 'ASC',
    'paged' => $paged
  );

  $the_query = null;
  $the_query = new WP_Query($args);

  if($the_query->have_posts()){ 
?>

    <section class="container libros-home">
        <div class="row justify-content-sm-between libros-destacados-autor" style="margin:2%;">

        <?php
            while($the_query->have_posts()) : $the_query->the_post();
        ?>  

                        <div class="card col-xs-3 col-sm-4 col-md-3 col-lg-3 col-xl-2 card-destacado" align="center">
                            <div class="autor-imatge">
                                <div class="rodona gran">
                                    <a href="<?php echo get_permalink() ?>" title="Santiago Posteguillo" itemprop="author"><img src="<?php echo get_field("portada")["url"] ?>" class="photo " itemprop="image"></a>
                                </div>
                            </div>
                            <div class="autor-info">
                                <span class="nom"><a href="<?php echo get_permalink() ?>" title="Santiago Posteguillo" itemprop="author"><?php echo the_title(); ?></a></span>
                            </div>
                        </div>

        <?php
            endwhile;
        ?>
            <div class="col-md-12 options border-bottom">
                <div class="container"> 
                    <div id="main">
                        <!-- pagination -->
                        <ul class="pagination">
                        <div>
                            <li class="page-item">
                                <span class="page-link"><?php echo get_previous_posts_link( 'Anterior'); ?></span>
                            </li>
                        </div>

                        <div>
                            <li class="page-item">
                                <span class="page-link"><?php echo get_next_posts_link( 'Siguiente', $the_query->max_num_pages ); ?></span>
                            </li>
                        </div>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </section>
<?php 
    }
    wp_reset_query(); 
?>

I hope you can help me, because between this and the problem I have to filter, I'm going up the walls.

    
asked by Alberto Escot 04.05.2018 в 00:50
source

0 answers