There are a number of scenarios where you may need to use custom post templates, but this example came about from a recent project using Cart66 Cloud to power an eLearning video course.
- Cart66 removes posts from the loop when protected, resulting in a 404 error if accessed before logging in
- Members need a page they can go to that allows them to manage their account, login to access secured content and navigate through the eLearning course.
- Protected posts and pages needed a custom layout different from standard posts and pages in the site
- Create a custom post and page template (yes, one template for both) for posts and pages in the membership course
- Add a filter to the functions.php file, in the theme, that applies the template to posts protected by the membership
Create the Template and apply the styles
The template page can be any design you want that works with your theme.
In this case, we took the front-page.php file of the Genesis Streamline-Pro Child Theme, saved it as, renamed the widgets and Genesis Meta.
Name the page template
add the template name just below the opening php tag on the page_elearning.php template file.
Add the widgets to the theme functions
Add the filter to your Theme Functions
That’s all she wrote for code
Now all that remained was to create a page, write some content and select the page template eLearning from the drop down. Then go to widgets and insert our login form and other member-specific information in the eLearning widgets.