/* Template page */ navigation show same posts on every page
-
Hi everyone,
I’m stuck with this problem for 3 days, and everything I’ve found on internet don’t seems to help me, so I’m totally lost.I’ve created a template page, and I’ve defined a category (namely : ‘events’) for posts in this page. My loop for them works fine, I’ve defined a maximum posts per page (5) and it’s also working great.
But anyway, when it’s time to create my navigation to go through page to page (in order to see the 5 nexts/previous posts), things messed up, and honestly I don’t know what and why. I can see the /page/2/, /page/3/… (etc) added in the URL but WordPress don’t load other posts than the 5 on the first page.
HTML version of the site is here so you can understand what I’m trying to achieve.
I want to reach the exact same result but in WordPress (as you guess)…
Here is my code:
<?php /* Template Name: évènements */ ?> <?php get_header(); ?> <body> <?php include 'nav.php' ?> <div id="banner" class="events"> <header> <h1>Evenements</h1> </header> </div> <div class="container"> <section id="subtitle"> <img src="<?php echo get_template_directory_uri(); ?>/img/bg-cd.png" class="cd"> <span class="the-subtitle">La Brique organise</span> </section> <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true"> <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $args['paged'] = $paged; query_posts($args); ?> <?php query_posts( array ( 'category_name' =>'events', 'posts_per_page' => '5')); ?> <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <div class="panel panel-default"> <div class="panel-heading" role="tab"> <h4 class="panel-title"> <a role="button" data-toggle="collapse" data-parent="#accordion" aria-expanded="false"> <img src="<?php echo get_field('flyers'); ?>" alt="La Brique <?php the_title(); ?>"> </a> </h4> <div class="arrow-up"></div> </div> <div class="panel-collapse collapse" role="tabpanel"> <div class="panel-body"> <div class="text-event no-padding col-lg-6 col-md-6 col-sm-6 col-xs-12"> <section class="night-title"> <img src="<?php echo get_template_directory_uri(); ?>/img/icon-night.svg" alt="flyers labrique" class="icon-night this-night visible-lg"> <hr class="between-line"> <span class="night-subtitle centered">ce soir-la</span> </section> <?php the_content(); ?> </div> <div class="no-padding youtube-video col-lg-6 col-md-12 col-sm-12 col-xs-12"> <section class="night-title"> <img src="<?php echo get_template_directory_uri(); ?>/img/icon-play.svg" class="icon-night"> <hr class="between-line"> <span class="night-subtitle">Video</span> </section> <div class="youtube-container"> <div class="youtube-player" data-id="<?php echo get_field('teaser'); ?>"> </div> </div> </div> <div class="no-padding more-infos col-lg-12 col-md-6 col-sm-6 col-xs-12"> <div class="no-padding col-lg-4 col-md-12 col-sm-12 col-xs-12"> <section class="night-title"> <img src="<?php echo get_template_directory_uri(); ?>/img/icon-clock.svg" class="icon-night centered"> <hr class="between-line centered"> </section> <p class="the-info"><?php echo get_field('date_et_heure'); ?></p> </div> <div class="no-padding-lg col-lg-4 col-md-12 col-sm-12 col-xs-12"> <section class="night-title"> <img src="<?php echo get_template_directory_uri(); ?>/img/icon-map.svg" class="icon-night centered"> <hr class="between-line centered"> </section> <p class="the-info"><?php echo get_field('lieu'); ?></p> </div> <div class="no-padding col-lg-4 col-md-12 col-sm-12 col-xs-12"> <section class="night-title"> <img src="<?php echo get_template_directory_uri(); ?>/img/icon-dollar.svg" class="icon-night centered"> <hr class="between-line centered"> </section> <p class="the-info"><?php echo get_field('prix'); ?></p> </div> </div> </div> <a class="close-btn red" role="button" data-toggle="collapse" data-parent="#accordion" aria-expanded="false"> <span class="first"></span> <span class="second"></span> </a> </div> </div> <?php endwhile; ?> <div class="col-lg-6" style="text-align:left; margin-top:25px;"> <?php if( get_next_posts_link() ) : next_posts_link( '? Prev' ); endif; ?> </div> <div class="col-lg-6" style="text-align:right; margin-top:25px;"> <?php if( get_previous_posts_link() ) : previous_posts_link( 'Next ?' ); endif; ?> </div> <?php endif; ?> </div> <div id="nav-pages" class="hidden"> <div class="into-nav-pages"> </div> </div> </div> <?php get_footer(); ?> <script src="<?php echo get_template_directory_uri(); ?>/js/jquery-1.12.0.min.js"></script> <script src="<?php echo get_template_directory_uri(); ?>/js/bootstrap.min.js"></script> <script src="<?php echo get_template_directory_uri(); ?>/js/tweenmax.min.js"></script> <script src="<?php echo get_template_directory_uri(); ?>/js/main.js"></script> <script> $(document).ready(function(){ $('footer').addClass('events'); $('.panel-collapse').collapse({ toggle: false }); $('#nav-pages a').addClass('box-into') }); </script> </body> </html>
I think it’s matter to tell you that I’m using “advanced custom field” plug-in (this why you have so many “echo get_field(‘name_of_the_field’)”), and I’ve modified everything on the “content.php” file to have the artists articles posts as I wish — it’s an other category, if you navigate through the website I gave you in the intro, you will understand what I’m talking about.
Thanks in advance, bye bye ladies and gentleman’s.
PS: sorry for my bad english, I’ve done the best I could.
- The topic ‘/* Template page */ navigation show same posts on every page’ is closed to new replies.