How to add pagination to my wordpress loop?
-
Hey there,
I try to create my first own WordPress theme and I got a problem because I want to show the current page the user is on and a forward/backward link at the bottom. The result should look like this: https://prnt.sc/b3xgq1
I’m using this loop:
<main id="main"> <?php // the query $args = array('posts_per_page' => 2 ); $the_query = new WP_Query( $args ); ?> <?php if ( $the_query->have_posts() ) { ?> <!-- loop --> <?php while ( $the_query->have_posts() ) { $the_query->the_post(); ?> <article id="post"> <div id="thumbnail"> <?php if ( has_post_thumbnail() ) { the_post_thumbnail(); } ?> </div> <h2><a href="<?php the_permalink();?>"><?php the_title(); ?></a></h2> <div class="entry"> <?php the_excerpt(); ?> </div> </article> <?php } } else { ?> <p><?php _e( 'Die Posts entsprechen nicht den Kriterien.' ); ?></p> <?php } ?> <!-- end of the loop --> <?php wp_reset_postdata(); ?> <div id="pagination"></div> </main>
I hope that someone explain me how to do this.
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘How to add pagination to my wordpress loop?’ is closed to new replies.