1

I want to have a custom front page and a blog page. So I created the front-page.php file, which will include my custom markup. I don't want to have blog post index on my front page, so I created home.php to feature blog posts index. How do I link to the blog page in this case?

3

Since WordPress 4.5 you can use get_post_type_archive_link( 'post' ) to link to the page containing the blog posts. Depending on what you've set under Settings -> Reading, this will be either the front page, e.g. example.com/ or a specific page like example.com/news/. home_url( '/' ) always points to the front page.

  • after I've created home.php (given thatfront-page.php also exists), do I still have to add new blank page in admin panel and point to it in settings>reading>static page>blog page, in order to have blog posts index appear in home.php? – qwaz Jan 15 '18 at 13:14
  • Yes. Otherwise how would WordPress know where the blog page is and when to load home.php? – swissspidy Jan 15 '18 at 13:20

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.