Hello! As I’m using a Multisite WordPress and sub domains are attached to it with different admins. I’m looking for a way to create multiple front-page, so my question is how could I do it? Thanks.
One way is to have a single
front-page.php and then using
get_template_part() , to show different content based on user choice.
get_header(); $layout = get_option( 'front_page_layout', 'default' ); get_template_part( 'front-page', $layout ); get_footer();
After that you need to create a file for every layout, they should be called, something like:
Last one will be used when the option is not set, e.g. when the the theme is just activated.
Of course, you need a page in backend where users can choose the template and save the ‘front_page_layout’ option.
Having only one
front-page.php it will be easily recognized by anyone seeing your theme without having to look at code.
Another alternative is just to use
front-page.php to contain the default layout, after that, you can create some alternative layouts using page templates.
/* Template Name: Home Page Alternative One */
In this way your users can create a page, assign to it one of the templates you have created and finally set this page as the front page in the reading settings.
After first time, to change home page layout users need only to change the page template of the page choose as static front page.
This second option require a bit more work for the users, but prevent you to have a theme settings page where to set the ‘front_page_layout’ option.