• Resolved FROM_ROB

    (@from_rob)


    Hello,

    I’m having some trouble with the next_posts_link() & previous_posts_link() on the homepage of my site.

    As I’m sure many people have noticed either of these links do not display if you are on the first or last page that displays blog posts.

    Is there a way to keep the next_posts_link() & previous_posts_link() visible on all pages even if technically the link cannot for backward or forward if you are on the first and last page of a site with blog posts?

    Ryan from 3 Roads Media wrote an excellent blog post that outlined a very simple method of how to fix next_post_link() and previous_post_link() functions from disappearing on the first and last pages when viewing single posts.

    Here is the post: http://www.3roadsmedia.com/blog/improving-wordpress-page-navigation/

    I am interested to do the exact same thing but have it applied to the next_posts_link() & previous_posts_link().

    Thanks in advance for everyone’s assistance. I look forward to figuring this out, as I’m sure others would too, since it has been plaguing me for some time.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter FROM_ROB

    (@from_rob)

    Additionally, I did think of a solution, although I am having difficult working out how to do it exactly.

    Basically my navigation is an include file that consists of ‘Previous’ (next_posts_link) and ‘Next’ (previous_posts_link) that I would like to be shown at all times.

    So I was thinking that for the homepage of my website that displays the latest posts in a typical blog fashion, I could include a different navigation (only on the homepage) that would display ‘Previous’ (next_posts_link) and ‘Next’ (with no link attached – just text) so that the ‘Next’ link doesn’t disappear.

    What would be the most logical way to go about this? Since at the moment my index.php file is acting as the template for all of the pages with blog entries.

    Thank you kindly.

    you can build it conditionally based on http://codex.wordpress.org/Function_Reference/get_next_posts_link and http://codex.wordpress.org/Function_Reference/get_previous_posts_link, resp.

    example:

    <div class="navigation">
    			<div class="alignleft"><?php if(get_next_posts_link()) { next_posts_link('&laquo; Older Entries'); } else { echo 'No Older Entries'; } ; ?></div>
    
    			<div class="alignright"><?php if(get_previous_posts_link()) { previous_posts_link('Newer Entries &raquo;'); } else { echo 'No Newer Entries'; } ; ?></div>
    		</div>

    Thread Starter FROM_ROB

    (@from_rob)

    YES!

    Amazing.
    This was exactly what I was looking for.

    Thank you alchymyth!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘FIX next_posts_link() & previous_posts_link() ON FIRST AND LAST PAGE.’ is closed to new replies.