How to get "previous page" (It doesn't exist)
-
Hello,
I’m customizing my own template for the first time and changed everything from the RedStamp template (Big mistake now I look back) but so far I find every answer I need in support of WordPress except for this one:
I’ve added this to show only 3 posts in my “news” feed
<?php query_posts(‘&posts_per_page=3’); ?>
And I wrote 5 test-posts, now this code is working but I can’t get to my “previous page” where the other 2 articles may be found.
I tried to find it in my own browser by adding /page/2 (=404 error)
or /2 or index.php/page/2 and so on, but I couldnt find it myself.So I went tried a couple of other codings people suggested but nothing got me to my other 2 posts.
The only thing that got me closest is:
<?php $pagelist = get_pages('sort_column=menu_order&sort_order=asc'); $pages = array(); foreach ($pagelist as $page) { $pages[] += $page->ID; } $current = array_search(get_the_ID(), $pages); $prevID = $pages[$current-1]; $nextID = $pages[$current+1]; ?> <div class="navigation"> <?php if (!empty($prevID)) { ?> <div class="alignleft"> <a>" title="<?php echo get_the_title($prevID); ?>">Previous</a> </div> <?php } if (!empty($nextID)) { ?> <div class="alignright"> <a>" title="<?php echo get_the_title($prevID); ?>">Previous</a> <a>" title="<?php echo get_the_title($nextID); ?>">Next</a> <!-- lol had to put both in "alignright because I still need to fix the css --> </div> <?php } ?> </div><!-- .navigation -->
But what happens is that this brings me to the third article on the page, not the (previous) index-view.. as if that page don’t exist. You can check it here:
https://www.huismanadvies.com/nieuws/
(ps. everything is still much under construction)How can I get my previous page working? or how can I find my previous page?
I’m a student webdesigner, writing a wordpress template is all new to me, but I can read and understand what is said most of the times. But I dont understand any of the navigationsystem so far……
Thanks for reading, I hope you can help?
- The topic ‘How to get "previous page" (It doesn't exist)’ is closed to new replies.