سؤال

I'm working on a site which has a fully customized front page. Now I'm asked to add a more classic looking blog type page which will be reacheable at http://domain/blog.

I tried creating a custom (empty) page called blog and put some code into page-blog.php, but the problem is that I can't get The Loop to work in there: the page render aborts right where the display of The Loop should start.

Is a custom page the wrong way to do it?

هل كانت مفيدة؟

المحلول

Assuming you are using WordPress v3.x (as I don't remember how this works in earlier versions) this is what you need to do if starting from scratch:

  1. Create a "Page" and call it "Home Page" (or whatever.)

  2. Create another Page and call it "Blog" (or whatever.)

  3. In the admin console select the "Settings" > "Reading" option.

  4. Select "A static page" for the "Front Page Displays" radio button.

  5. Assign "Front Page" to be "Home Page" (or whatever from #1)

  6. Assign "Posts Page" to be "Blog" (or whatever from #2)

  7. Click "Save Changes"

  8. You're done.

Here's a screenshot showing the admin console options:


(source: mikeschinkel.com)

نصائح أخرى

What did you use for your front page, customized index.php or home.php? Is it static or still contains Loop of posts?

Configuration you want is supported by WordPress, but little confusing to explain. See Creating a Static Front Page in Codex.

Essentially approach of creating pages for this is correct, but you must set it up in WordPress and be aware of template technicalities, so that everything works properly.

you can also play locate_template() function, see this tutorial: http://wpengineer.com/2030/create-a-separate-page-for-blog-posts-in-wordpress/ for creat a seperate blog page and creare the home.php in the Theme als static homepage.

If the objective is to get a blank page, then the suggestions above will only work on certain wordpress themes.

Certain themes have permanent widget data on them even if you perform the procedure suggested by Mike.

The only way I've found that Mike's suggestion works is if the page has an 'Alternative Home' function, which is located in the edit section of the page, on the right side under the Template category; which again only comes with certain templates (Thesis, Elegant).

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى wordpress.stackexchange
scroll top