(This tutorial is a modified version of Brad Dalton’s Add Latest Posts With Pagination To Front Page With Widgets Where he has provided the front-page.php code for News Pro Child Theme. Please do refer to his article to understand this code.)
Most StudioPress themes include a front-page file which normally includes widgets.
If you also want to include your latest posts dynamically, you can enable the standard loop before or after the widget areas.
Another option is to add a custom grid loop that also enables you to display your posts in a grid type layout or simply as features that are like the standard loop archive.
The only problem is, it may not generate pagination.
In this tutorial, I will show you how to Add Latest Posts with Pagination to Front Page with widgets on Magazine Pro Genesis Child Theme.
I will provide the entire front-page.php template which includes all the code tested on the Magazine Pro Genesis Child Theme. You can modify the classes to fit in with your existing themes classes.
Here it is:
If you simply added a custom loop or grid loop to our home or front page template file you would suffer these problems:
- It wouldn’t include pagination
- If it did include pagination, the 2nd and subsequent paginated pages will also include the widgets you have coded in your template file to display on every paginated page.
The code above includes the solutions to solve both problems so:
- Only your front page includes the widgets
- All paginated pages linked to your front page only display your standard loop like a posts page without widgets.
On top of this, you can also choose how you want your posts displayed:
- In a grid loop, 2 excerpts side by side
- The first post in full and the rest excerpts.
- Full content width featured and then grid excerpts.
Confused? Here’s what the front page & paginated pages look like after adding the code.
And here’s what the 2nd and subsequent paginated pages look like without the home page widgets.
If you enjoyed this article, you can also read Easy Steps to Start a WordPress Blog and Make Money.
- How to Build a Custom WordPress Theme from Scratch
- How to Create your First WordPress PlugIn
- Best WordPress Cheat Sheets For Designers And Developers
- 18 Traffic Boosting Tips for Your WordPress Blog
- How to Show Content to Users Only Once – WordPress Cookies