Link going to oldest to newest posts
-
So I have a “View All” link to display 10 posts per page in a list format. When user clicks “View All” it takes you to page starting with the most recent post, which is great! However, that first landing page only has a previous button which takes user to later posts.
Here’s the code for the “View All” link:
<div class="view-all"><a class="title-caregory-search" href="<?php bloginfo('url'); ?>/recipes/appetizers/" title="VIEW ALL">VIEW ALL</a></div>
I can do a temp fix by changing the url to the last page (/recipes/appetizers/page/2/, but if I were to add more appetizers and add a third page, I’d be back where I started.
Here’s the code for the “Next” and “Previous” button:
/** * Display navigation to next/previous pages when applicable */ function twentyeleven_content_nav($html_id) { global $wp_query; if ($wp_query->max_num_pages > 1) : ?> <nav id="<?php echo esc_attr($html_id); ?>"> <h3 class="assistive-text"><?php _e('Post navigation', 'twentyeleven'); ?></h3> <div class="nav-previous"><?php next_posts_link(__('<span class="meta-nav">←</span> Previous', 'twentyeleven')); ?></div> <div class="nav-next"><?php previous_posts_link(__('Next <span class="meta-nav">→</span>', 'twentyeleven')); ?></div> </nav><!-- #nav-above --> <?php endif; } endif; // twentyeleven_content_nav /**
Any help is much appreciated. Thanks!
- The topic ‘Link going to oldest to newest posts’ is closed to new replies.