Create a pagination in wordpress

0

In my wordpress I created a menu in the Backand called "Opinions". This I have put as a loop on my page, so that it shows the last 10 post.

<div class="container">
    <?php
        $categories = get_categories( array(
            'child_of'=>'Opiniones'
        ) );

        $subcategories = array();

        foreach ( $categories as $category ) {
            $subcategories[] = $category->cat_ID;
        }
    ?>

    <?php
        $new_loop = new WP_Query( array(
        'post_type' => 'Opiniones',
        'category__in' => $subcategories,
        'posts_per_page' => 10
        ) );
    ?>

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




    <div>

        <hr/>

            <div class="info">
                <div class="autor"><p><?php the_field('autor-title'); ?></p>&nbsp;<strong><p><?php the_field('autor'); ?></p></strong></div>
                <div class="datum"><p><?php the_field('datum_title'); ?></p>&nbsp;<strong><p><?php the_field('datum'); ?></p></strong></div>

            </div>

            <h2><?php the_title(''); ?></h2>


            <?php the_content(''); ?>



    </div>



    <?php endwhile; else: ?>
    <?php endif; ?>
    <?php wp_reset_query(); ?>

    </div>

Now what I need is to create a Pagination below so that the visitor can go back and see the previous posts but only from the "Opinions" menu. I am quite new in this and there are still things that escape me. Thank you all

    
asked by Dario B. 12.10.2017 в 09:46
source

1 answer

0

For wordpress pages I use a standard loop:

<?php query_posts( array( 'category_name' => categorias, 'paged' => get_query_var('paged') ) ); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

    <!-- Aquí va el contenido HTML --> 


<?php endwhile; ?> 
        <?php posts_nav_link(); ?>
<?php else : ?>
<?php endif; ?> 

I leave you the paging documentation: link

    
answered by 12.10.2017 / 16:03
source