2

This may seem like a stupid question, and it probably isn't possible, but is it possible for me to set a static home page (using front-page.php) and a blog page (using home.php, I think) in my theme, and have the blog page appear on a separate slug WITHOUT changing the page settings in my Wordpress installation, under Settings > Reading? So http://www.mysite.com/blog/ will show my blog (home.php), and http://www.mysite.com/ will show my home page (front-page.php)?

EDIT I should point out, as I didn't point it out so explicitly earlier, I would like to avoid creating the pages in Wordpress, if I can. Although @eyedarts does answer the question, it doesn't give completely what I need. Although that may well have been my fault for not explaining that.

2 Answers 2

1

The answer appears to be that it is possible:

http://codex.wordpress.org/Creating_a_Static_Front_Page

Configuration of front-page.php

If it exists, the front-page.php template file is used on the site's front page regardless of whether 'Settings > Reading ->Front page displays' is set to "A static page" or "Your latest posts," the Theme will need to account for both options, so that the site front page will display either a static page or the blog posts index. There are a few methods to do so.

As for the blog page, I think you can find what you're looking for here:

http://codex.wordpress.org/Page_Templates

Specialized Page Template

Create a template for one Page: For more extensive changes, intended for just one specific Page, you can create a specialized template file, named with that Page's slug or ID:

    page-{slug}.php
    page-{ID}.php

In that specialized/custom template file, use the get_posts() function (http://developer.wordpress.org/reference/functions/get_posts/) and other similar functions to get and list the posts.

You can use the add_posts_page() function (http://developer.wordpress.org/reference/functions/add_posts_page/) to add the page to the menu.

So, in your front-page.php, you'll have a reference to a static page that you create in your code. You'll then also create a second page for your blog page using the specialized page template.

I'd be curious to know if there's an easier, more straight-forward way to do this.

3
  • I know that front-page.php will override the home page, but page-{slug}.php doesn't seem to work for the blog; it throws up a 404 error page instead. It was something I had tried before, but to no avail. Unless there is something that I have forgotten to add somewhere.
    – Nate
    Commented Sep 5, 2014 at 21:58
  • My understanding of the page-{slug}.php pages is that it still requires a page to be set up in Wordpress, in order that it pulls the slug in. I would like to avoid that, if possible.
    – Nate
    Commented Sep 5, 2014 at 22:00
  • Yeah, I get that. Hopefully someone else will help as I'm curious about this too.
    – eyedarts
    Commented Sep 5, 2014 at 22:29
-1

Create the home.php and rewrite the address in your .htacess file in the main wordpress folder.

Just below this

RewriteEngine On    

Add this

RewriteRule    ^/home/$    http://www.example/blog/    [301,L]

If you later change the permalinks in WP admin page this line may be overwritten and you may have to add it again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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