I have restricted to display 20 posts on index.php, but also I want to add a link to display all posts without restrictions. Any advices on how to achieve this? Thanks!
|
You could create a template called all-posts.php and place this code inside of it:
Now you would save that file, upload it to your theme's main directory. Next you could create a page called All Posts, or whatever you wanted. When you are in the New Page or Page Edit screen, just choose the new template you just made called All Posts from the Page Attributes drop-down list in the right side of the edit pages screen. Click update and add the page to your menu. You will now have a page that shows all posts. You can copy the URL and use it to link to all posts from the page you are speaking of. REVISED TO SHOW HOW TO ADD "NEW DIV" There really isn't a need to add an extra div tag for this template. Each post will have it's own id by default. If you use Firefox you can install one or both of the following plug-ins to inspect each post for it's unique ID: Once you have them installed get familiar with the available tools and you'll have access to lots of valuable data. I'm going to past the code again with a new div added just in-case you don't figure out how to identify the posts as I've explained. Code with new DIV Tag:
The new DIV is the one called "new-div". You can add a little css to the new div so you can see it in action. Just add this to your style.css file for a red border (just for testing purposes):
|
|||||||||||
|