Wordpress - Is it possible to use a single custom post as the site front page
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:
function add_pages_to_dropdown( $pages, $r ){
if ( ! isset( $r[ 'name' ] ) )
return $pages;
if ( 'page_on_front' == $r[ 'name' ] ) {
$args = array(
'post_type' => 'portfolio'
);
$portfolios = get_posts( $args );
$pages = array_merge( $pages, $portfolios );
}
return $pages;
}
add_filter( 'get_pages', 'add_pages_to_dropdown', 10, 2 );
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:
- Mark the blog post as sticky, and then set Posts per Page to 1 (
Dashboard -> Settings -> Reading
) - Create a custom
front-page.php
template, and query the post in question, either via the sticky post designation, or via custom post meta - Create a custom
front-page.php
template, and create a dynamic sidebar (i.e. Widget area), in which you add a Widget to display the post in question - (Insert lots of other methods here...)
But 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:
Well it's a client's requirement, I created a custom post type called "portfolio" where he adds all the work he's done and he just wants one of those posts to display as the homepage, exactly as if you would set a static front page in the reading settings, updating question.
You would need to use one of the following methods:
- Filter the
page_on_front
dropdown, as @EAMann suggests - Create a
front-page.php
template file, that queries the correct Portfolio post, via custom post meta or other means