I know I can set a static page as the homepage but is it possible to set a single custom post as the site front page?
I created a custom post type called “portfolio” where users can add all the work they have done as posts and I need one of those posts to display as the homepage, exactly as if you would set a static front page in the reading settings.
Thanks in advance!
You don’t want a post to be the front page, you want a custom post type entry to be the front page. Now that we have the terminology right, yes it’s possible.
A client once asked me to do the exact same thing. They had a custom post type they needed displayed on the front page. Doing so was as simple as adding a filter to allow them to select a “stack” (their custom post type) from the reading page:
Then it’s just a matter of styling your templates to use the data correctly.
There are many ways to accomplish this, though some are more advanced than others:
Dashboard -> Settings -> Reading
)front-page.php
template, and query the post in question, either via the sticky post designation, or via custom post metafront-page.php
template, and create a dynamic sidebar (i.e. Widget area), in which you add a Widget to display the post in questionBut I have to ask: why not just put that blog post content in a static Page, and then assign that static Page as the Front Page?
Edit
Based on your question clarification:
You would need to use one of the following methods:
page_on_front
dropdown, as @EAMann suggestsfront-page.php
template file, that queries the correct Portfolio post, via custom post meta or other meansHow about setting a custom meta field for “Use as Homepage”, then query for that meta and get the associated post(s) and output them…naturally all of this would be in
front-page.php
EAManns answer is good but does nothing if there are no pages at all in the database (since the option to choose static front pages is hidden if no pages are created). This is my attempt to fix this:
(Where ‘area’ should be substituted with the name of your custom post type.)
Have tried solution by EAMann it works, but as fiskhandlarn noticed it doesn’t work if there are no pages at all. And his solution didn’t worked for me.
So I suggest another solution may be too straightforward, but it do the work.
You can create new static page, create new template for this page and in template add