• I’m using block themes.

    I’d like the front page / home / index to show some extra blocks plus the list of blog posts. However, I want the paginated pages (e.g. /page/2) to not have these extra blocks and only show the list of blog posts.

    My question is: is there a way to use a different template for the index and another different template for the index’s paginated pages?

Viewing 4 replies - 1 through 4 (of 4 total)
  • I think you’ll be able to achieve what you have in mind by creating a front-page.php template for your frontpage and possibly also adjusting the index.php template for your paginated pages.

    You’ll find more information about this in the WordPress template hierarchy.

    I hope that helps get you in the right direction…

    Moderator bcworkz

    (@bcworkz)

    Apparently Dave missed the part where you use a block theme which does not use .php templates. However, it’s the same concept for .html templates. Create a front-page.html template and it’ll be used only on your home page.

    When you customize templates, it’s best to create a child theme to keep them in.

    Your other option would be to create a normal WP page to be your home page, using the query loop block to list a posts archive. Then in settings, set this page as your static front page. You should also create another WP page to act as the blog listing page. It needn’t have any content, nor do you really need to even use it, but you need something to choose when you also specify a static home page.

    Thread Starter w0rdpr3ss3r

    (@w0rdpr3ss3r)

    Unfortunately, the issue appears to be the pagination pages are not distinctly differentiated from the homepage. I’ve tried setting a static page to be the homepage but paginating to the second page, it still shows the homepage.

    Moderator bcworkz

    (@bcworkz)

    It could be tricky getting a query loop block to paginate (static home page option). You’re probably better off with the latest post home page option.

    To achieve your goal with lastest post option, copy your theme’s index.html template to the same folder within a child theme you’ve created. Rename the copied file to front-page.html. Modify this file to include a custom PHP pattern you will create.

    The custom pattern will conditionally output the desired first page blocks only when the “paged” query var of the global $wp_query object is either undefined, empty, or 1. If “paged” is any other integer besides 1, output nothing.

    You may also include any other custom code you might want in this same child theme.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Block Theme: How to use a different template on front page vs paginated pages?’ is closed to new replies.