I am attempting to do something similar to the accepted answer on this question Is it possible to use a single custom post as the site front page

My problem is that this implementation causes a redirect.

So for example if I add the code below to twentyeleven functions.php on a default WordPress install, and then select the Hello World post from the reading->front page drop down my home url such as mysite.com will redirect to mysite.com/?p=1. So it is impossible to actually stay on the home page because of this redirect.

Is it possible to avoid this redirect? If so, the solution below will be great for showing a post or custom post as the home page.

add_filter( 'get_pages', 'add_pages_to_dropdown', 10, 2 );

function add_pages_to_dropdown( $pages, $r ){
    if ( ! isset( $r[ 'name' ] ) )
        return $pages;

    if ( 'page_on_front' == $r[ 'name' ] ) {
        $args = array(
            'post_type' => 'post'

        $portfolios = get_posts( $args );
        $pages = array_merge( $pages, $portfolios );

    return $pages;

I'll just copy/paste my answer to that question, here:

There are many ways to accomplish this, though some are more advanced than others:

  1. Mark the blog post as sticky, and then set Posts per Page to 1 (Dashboard -> Settings -> Reading)
  2. Create a custom front-page.php template, and query the post in question, either via the sticky post designation, or via custom post meta
  3. 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
  4. (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?


Also: be sure that you have pretty permalinks enabled, via Dashboard -> Settings -> Permalinks.

  • Chip, your first solution simply shows the post on the home page as if it was an archive. It does not show the actual post. Your second and third options are not relevant to the question... Also, it is not possible to make a custom post type sticky without the use of a plugin. – Mike Apr 11 '12 at 16:02
  • 1
    What's this about "custom post type"? Your question referenced using single blog posts, not custom post types. – Chip Bennett Apr 11 '12 at 16:24
  • Yeah, if I can get a post to work, I should not have a problem getting a CPT to work. The real issue here is avoiding the redirect – Mike Apr 11 '12 at 16:33
  • But CPTs are covered in the other question. Refer to that question for CPTs. – Chip Bennett Apr 11 '12 at 16:37
  • Also, the second and third examples are absolutely relevant to the question. Both are effective means to display a single blog post as the site front page. – Chip Bennett Apr 11 '12 at 16:55

My solution so far has been to take the reading->front page option out of the equation and go with a custom post type settings page.

Adding a settings page requires a bit of code but it can be done starting with the add_submenu_page(); function.

Then you can use the pre_get_posts action to alter the query by using that option you set like so

add_action( 'pre_get_posts', 'my_pre_get_posts' );

function my_pre_get_posts($query){
        $option = get_option('my_option');
                $query->set('p', $option);
                $query->set('post_type', 'post');


This allows you to avoid having to create a front-page.php file which could be a duplication of a more specific theme file. The drawbacks to this are obvious, you now have an extra settings page. Not sure there is really a "correct" answer to this one.


You can just make a copy single.php and name it home.php and put it in your theme folder. Wordpress will use that as a home now. Ref: http://codex.wordpress.org/Template_Hierarchy

Then you just change the loop inside your home.php (based on single.php) to look like it's explained here: http://codex.wordpress.org/Function_Reference/query_posts#Retrieve_a_Particular_Post

So this:

if ( have_posts() ) while ( have_posts() ) : the_post();

Becomes this:

query_posts( 'p=5' );
if ( have_posts() ) while ( have_posts() ) : the_post();

Where the line "query_posts" specify the postID that you want as a home (check that on wp-admin side). In the example, p=5 will query for postID = 5.

Or you can just redefine a new loop using http://codex.wordpress.org/Class_Reference/WP_Query method to ensure nothing else be broken with the new loop.

Pretty neat and simple.

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.