2

How do I make my single-work page show on my front-page.php?

So I want to show my work page on the homepage. For example, my work page link is www.example.com/work but I want to show the work page in www.example.com. Should I use gettemplate code?

1

No CODE is necessary for this.

Go to WordPress Admin Panel → SettingsReading.

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:

Select a static page as home page.

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:

custom template

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 select Page Attributes from top right Screen Options drop down menu.

  • Thank you but when I checked the "a static page" and for homepage and post page I can't see "work" My single-work.php is not showing there. I use custom field for my work page. – waisie li Aug 11 '18 at 20:59
  • i have single-work.php . I need to name it like that because it's a blog. I just want my blog to show in the homepage. Is there another to do that? – waisie li Aug 11 '18 at 21:41
  • I also have a archive-work.php . – waisie li Aug 11 '18 at 21:43
  • Ok, I select Your latest posts but is not showing on my front-page.php . Do you know why? – waisie li Aug 11 '18 at 22:11
  • yes it's in my theme folder. – waisie li Aug 11 '18 at 23:28
0

Create a new file as named work.php in your theme directory folder and add this code top of the file:

<?php 
/*
Template Name: Work
Template Post Type: page
*/
?>

Your codes here...

Go -> Pages, edit your Work page. And select page template as Work

And go reading settings. Select front page as Work

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.