No CODE is necessary for this.
Go to WordPress Admin Panel → Settings
→ Reading
.
Then from the option Your homepage displays
, select A static page (select below)
& then in the Homepage:
dropdown menu, select your Work
page & Save Changes.
Like the screenshot below:
Of course, once you’ve done this, your Work
page content will be loaded on the site home page (e.g. www.example.com
) with proper home page template (e.g. front-page.php
) of your theme.
Check the Template Hierarchy document to learn which theme template will handle the home page in different situations.
Custom Home Page Template
Say you have a template file (within the theme) named single-work.php
and another template file front-page.php
. According to WordPress template hierarchy, front-page.php
will load the home page, regardless of the setting Your latest posts
or A static Page
.
You can change that if you choose A static page
. Let’s say you have a static page named Work
& you select this page as your Homepage
. Now, first, put the following CODE at the top of single-work.php
template file:
<?php
/* Template Name: Work Template */
Then edit work
page and you’ll see the Template selection option under Page Attributes
:
From there, select Work Template
and save. That way, the home page will load using single-work.php
template instead of front-page.php
.
Note: if you don’t see the
Page Attributes
meta box, then selectPage Attributes
from top rightScreen Options
drop down menu.