Older Posts
-
Is there a way at the bottom of the homepage to have a link to older posts like in traditional blogs?
-
There are two ways:
Note: If you choose the first option, test it on a dummy-site first to see how it works for you. It is not necessary to create a child theme, because this is only html and css, no php, nothing in it will cause a crash, if pasted correctly. Update issue: Just save the lines below, so you can use them again after an update (If the basic structure doesn´t change).1st option: You create a new category as a parent of all of your current categories. Name it “Blog” or something like that. Then, go to home.php and put this between
<!-- End Articles. -->and<?php endif; ?>:<a href="http://www.yoursite.com/category/blog/page/3/" target="_self" style="text-decoration:none"> <div id="Oldones"> <span style="color:white"> <center>Older posts</center> </span> </div> </a>Replace “yoursite.com” !
Set the number of articles shown in the slider to 3 in the slider section after “posts per page” ( near top of home.php ).
Be sure you have always set a post to “Featured”.
Have the homepage showing 10 posts for “newsfeed” in General Settings-> Reading (due to me using the german version of wordpress, I don´t know the exact terms of the interface) .
So, now you have 14 posts on the homepage, because of the “no duplicate” function.
That´s why the link above works with the 3rd page of your “Blog”-category.
You also have to set the number of posts on blog-pages to 7 (Settings -> reading).
Now the first two pages of archive-pages (including your parent-category) show each 7 posts on the first and second page, means the third page begins with the 15th post.Also, put this into your Custom Css box in Leaf Options:
#Oldones { position: absolute; background: #444; color: #fff; padding: 6px 9px 5px 9px; padding: .6rem .9rem .5rem .9rem; text-decoration: none; width: 100px; width: 10.0rem; right: 20px; right: 2.0rem; } #Oldones:hover { color: #fff; background-color: #accentcolor; }Replace #accentcolor !
All that color-stuff will make that button look like the built-in pagination.
Now, when someone clicks that “Older posts”-button, that person will get to page 3 of all of your posts and the built-in pagination will display. But, if you go to page 1 of that Archive, you won´t get to the homepage again.Adding a Home-button on those pages:
Go to your archive.php .
Paste the following code between</div><!-- #content -->and</section><!-- #primary .site-content .<?php echo leaf_grid_width( 'content' ); ?> .columns -->:<a href="http://www.yoursite.com" target="_self" style="text-decoration:none"> <div id="homelink"> <span style="color:white"> <center>Home</center> </span> </div> </a>Again, replace “yoursite.com”!
Paste this into your Custom Css Box in Leaf Options:#homelink { position: relative; background: #444; color: #fff; display: block; padding: 6px 9px 5px 9px; padding: .6rem .9rem .5rem .9rem; text-decoration: none; width: 100px; width: 10.0rem; left: 0; bottom: 8px; bottom: 0.8rem; z-index: 5000; } #homelink:hover { color: #fff; background-color: #accentcolor; }Again, replace “#accentcolor”!
And have a div around the pagination like this:
<div id="mypagination"><?php leaf_pagination(); ?></div>
You only have to add<div id="mypagination">and</div>
<?php leaf_pagination(); ?>already exists!
Also paste this into that Custom Css Box:#mypagination { position: relative; bottom: 30px; bottom: 3.0rem; z-index: 5000; right: -20px; right: -2.0rem; }This is a solution requiring a bit of mathematical understanding and effort, but comes along using solely html and css.
2nd Option:
This solution is way easier. But it won´t work perfectly.
Have a look at http://ww.wp.xz.cn/support/topic/pagination-issue-10?replies=3It is not necessary to create a child theme, because this is only html and css
That is totally and utterly wrong! Never edit the parent theme – whether it’s PHP, HTML or CSS you want to change. Always make your changes in a child theme.
In addition, Leaf theme has a child-theme ready, you have only to download it
This solution is way easier. But it won´t work perfectly.
For me works perfectly.
My doubt was only on the code writing, but it works.
But it’s for pagination (1,2,3…), not for “older-newer posts”
The topic ‘Older Posts’ is closed to new replies.
