• Resolved gaznev2000

    (@gaznev2000)


    Hi All. I’m having issues with the previous post links at the bottom of my pages. I have tried using the wordpress php:

    <?php next_posts_link('? Older Entries') ?>
     <?php previous_posts_link('Newer Entries ?') ?>

    Example here

    I have also tried a Plugin version using PageNavi
    <?php wp_pagenavi(); ?>
    Example here

    However, I am having the same problem with both techniques. If I choose older poses it loads page two, but the posts stay the same.
    You can test it on both of the links above.

    Has anyone got any idea why this might be happening.

    Below is the code from one of the the page-template using the wordpress php:

    <?php
    /*
    Template Name: Food and Travel - Eat
    */
    get_header(); ?>
    
    	<div id="content" class="narrowcolumn" role="main">
        <div class="homeHolder">
            <ul id="myRoundabout">
                <?php
    	    $catID = 188;
    		if ($catID) {
    		$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("cat=$catID&paged=$paged");
    				} ?>
    
    	<?php if (have_posts()) : ?>
    	<?php while (have_posts()) : the_post(); ?>
               <li class="item1"><a>"> <span class="img-title"><?php the_title(); ?></span><?php the_post_thumbnail(); ?></a>
    				<?php endwhile; ?>
    
             <?php else : ?>
             <!-- <h2 class="center">Not Found</h2>
             <p class="center">Sorry, but you are looking for something that isn't here.</p>
             <?php /*?><?php get_search_form(); ?><?php */?>-->
    
             <?php endif; ?>
    
    	</div>    
    
         <div class="home-hr"><img src="https://www.macsmagazine.com/wp-content/themes/macs/_assets/hr-line.jpg"/></div>
            <div class="homepage-heading"><a href="https://www.macsmagazine.com/living/diet-and-fitness/">Eat</a></div>
          	<div class="home-hr"><img src="https://www.macsmagazine.com/wp-content/themes/macs/_assets/hr-line.jpg"/></div>         
    
    	<div class="sub-stories-holder">
    
    <?php
    if ($catID) {
            $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
            query_posts("cat=26&paged=$paged");
            } ?>
    		<?php if (have_posts()) : ?>
    		<?php while (have_posts()) : the_post(); ?>
            <div <?php post_class() ?> id="post-<?php the_ID(); ?>">
            <div id="sub-post">
            	<div class="post-content">
                    <div class="post-thumbnail">
                        <a>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_post_thumbnail(); ?></a>
                    </div>
                    <div class="post-copy">
                        <div class="post-title">
                        <a>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
                        </div>
                        <span style="text-decoration:none;"><a>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">Read more ></a></span>
                    </div>
                </div>
            </div>
    		</div>
    
    		<?php endwhile; ?>
              <div class="navigation">
            <div class="alignleft"><?php next_posts_link('? Older Entries') ?></div>
            <div class="alignright"><?php previous_posts_link('Newer Entries ?') ?></div>
            </div>
    
    		<?php else : ?>
           <!-- <h2 class="center">Not Found</h2>
            <p class="center">Sorry, but you are looking for something that isn't here.</p>
            <?php /*?><?php get_search_form(); ?><?php */?>-->
    
    		<?php endif; ?>
    
          </div>
          </div>
    
    <?php get_sidebar('foodtravel'); ?>
    
    <?php get_footer(); ?>

    [mod: the above code is partially broken – don’t use it for copy/paste]

    Regards
    Gary

Viewing 5 replies - 1 through 5 (of 5 total)
  • you code per-se seems to be ok.

    however, the slider is possibly interfering;

    what is the full code of the slider, and is its query properly reset after the loop?

    Thread Starter gaznev2000

    (@gaznev2000)

    The full code of the slider is

    <div class="homeHolder">
            <ul id="myRoundabout">
                <?php
    	    $catID = 188;
    		if ($catID) {
    		$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("cat=$catID&paged=$paged");
    				} ?>
    
    	<?php if (have_posts()) : ?>
    	<?php while (have_posts()) : the_post(); ?>
               <li class="item1"><a>"> <span class="img-title"><?php the_title(); ?></span><?php the_post_thumbnail(); ?></a>
    				<?php endwhile; ?>
    
             <?php else : ?>
             <!-- <h2 class="center">Not Found</h2>
             <p class="center">Sorry, but you are looking for something that isn't here.</p>
             <?php /*?><?php get_search_form(); ?><?php */?>-->
    
             <?php endif; ?>
    
    	</div>

    Im not sure if the query is reset properly. I’m relatively new to nesting loops and i still don’t really know if i’m doing it correctly.

    The full page code is above; there has been a mod on it saying “partially broken ” but i can assure you that that is the full code in the page-tempate

    try to add wp_reset_query(); after the endif;

    generally a secondary query should not be programmed with query_posts() but rather using WP_Query() – read https://wordpress.stackexchange.com/questions/1753/when-should-you-use-wp-query-vs-query-posts-vs-get-posts?rq=1

    there has been a mod on it saying “partially broken “

    that remark is by me – to point out that the code here was somehow corrupted when it was posted; I am sure the code in your site is OK.

    Thread Starter gaznev2000

    (@gaznev2000)

    Thanks for your help, is this your full time job :-). It seems every time I run in to problems you seem to pop up. You are as they say a WPL (word-press-legend).

    I tried to wp_reset but it changed nothing. The site I’m woking on is so old its based on the Kubric theme, could that be the issue? how would you go about implanting the wp_Query in to the code below, should i rewrite it from scratch? I only ask as I’ve never used wp_Query before,

    <?php
    if ($catID) {
            $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
            query_posts("cat=26&paged=$paged");
            } ?>
    		<?php if (have_posts()) : ?>
    		<?php while (have_posts()) : the_post(); ?>
            <div <?php post_class() ?> id="post-<?php the_ID(); ?>">
            <div id="sub-post">
            	<div class="post-content">
                    <div class="post-thumbnail">
                        <a>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_post_thumbnail(); ?></a>
                    </div>
                    <div class="post-copy">
                        <div class="post-title">
                        <a>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
                        </div>
                        <span style="text-decoration:none;"><a>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">Read more ></a></span>
                    </div>
                </div>
            </div>
    		</div>
    
    		<?php endwhile; ?>
              <div class="navigation">
            <div class="alignleft"><?php next_posts_link('? Older Entries') ?></div>
            <div class="alignright"><?php previous_posts_link('Newer Entries ?') ?></div>
            </div>
    
    		<?php else : ?>
           <!-- <h2 class="center">Not Found</h2>
            <p class="center">Sorry, but you are looking for something that isn't here.</p>
            <?php /*?><?php get_search_form(); ?><?php */?>-->
    
    		<?php endif; ?>

    Regards
    Gary

    Thread Starter gaznev2000

    (@gaznev2000)

    Ok i manged to fix the issue i had to use the wp_reset_query(); after the endif; and I i used an array in the loop like this to:

    <div class="sub-stories-holder">
    
    		<?php
    		$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
            $args = array(
    		'cat' => 26,
    		'paged' => $paged
    		);
    		query_posts($args);
    		 ?>
    		<?php if (have_posts()) : ?>
    		<?php while (have_posts()) : the_post(); ?>
            <div <?php post_class() ?> id="post-<?php the_ID(); ?>">
            <div id="sub-post">
            	<div class="post-content">
                    <div class="post-thumbnail">
                        <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_post_thumbnail(); ?></a>
                    </div>
                    <div class="post-copy">
                        <div class="post-title">
                        <a  style="color:#000000;" href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
                        </div>
                        <span style="text-decoration:none;"><a  style="color:#bab69f;" href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">Read more ></a></span>
                    </div>
                </div>
            </div>
    		</div>
    
    		<?php endwhile; ?>
            <?php wp_pagenavi(); ?>
    
    		<?php else : ?>
           <!-- <h2 class="center">Not Found</h2>
            <p class="center">Sorry, but you are looking for something that isn't here.</p>
            <?php /*?><?php get_search_form(); ?><?php */?>-->
    
    		<?php endif; ?>
    
    		<?php wp_reset_query(); ?>
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Having issues with "Previous-posts-link" at the bottom of my pages.’ is closed to new replies.