سؤال

I am creating my first WordPress theme with a one-page parallax scrolling style. I have created my entire website (statically) in the index.php file. It works fine if I set the Admin->Reading setting to 'Your Latest Posts'.

But now I am trying to create a separate page for the blog so I did the following:

  1. I created a file, page.php, with the standard blog page code and gave it a template name.
  2. I set the Blog page on wordpress to use the Blog template.
  3. All other pages (i.e. home, about us, etc.) are set to use default page template (which should be index.php right?)
  4. I set the Reading settings to Front Page: Home and Posts Page: Blog

All I get is the blog page template for all pages (as if it were the default page template).

How to set up a website like this?

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

المحلول

index.php should really be your blog template not your static home page. Make a copy of page.php to page-home.php (or whatever you've named your front page), then put the static content in there. You probably won't even need to assign the template to the page - WordPress will do that automatically based on the file name.

By default, page.php is used for all static pages, index.php is used for whatever you've assigned as your blog page in the "Reading" section of the dashboard. index.php is also the template of last resort, which will be used if WordPress can't find any other appropriate template files.

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