• I started to create my first WordPress theme from scratch a couple of days ago. The theme is made for a portfolio website and for that I want several sections and templates for the site. The sections are a portfolio view (like a grid with all the projects assembled), a project view (a page/post for each project) and a page with news (like a simple blog view).

    I began with creating the index.php using a HTML template that I originally made for the project view. The project view contains a slideshow in the top.

    Then I created a new page called “Works” and made a second page template for that page called “portfolio”. Here I put the grid and then put a loop of a custom post-type called “portfolio-item” that created an image and a link to each project.

    From what I have understood, the index.php should be made as a template for the blog posts, and maybe not as a template for a custom post-type. Now when I want to create a page that lists every post (not the “portfolio-item” post-type, but just regular blog posts), it’s set in the template that I made for the project view, so each post gets a slideshow at the top.

    Is there any way to assign a different template to regular posts or how would I do this the easiest way? Please get back to me if anything’s unclear (it’s pretty hard to explain).

Viewing 1 replies (of 1 total)
  • Hello,
    I think this link could help you,
    it is a graphic interactive diagram of the WordPress template hierarchy, which is responsible for selecting the correct template to display.
    Those are part of the Theme Handbook, which goes through all the process for creating a new theme.
    A quick reference to theme development can be found here.

    Also, but I don’t know in your case, you may speed up your theme development if you begin with a starter theme link Underscores, made by Automattic, which also has a useful Generator you can use to customize your starter theme.
    There are also some video courses around, but most useful are code comments in the theme templates itself.

    This way you start with all the right tools you need to make a clean and well-coded theme with attention on security, accessibility, etc..

    I hope those link can help you as they did for me many times, and feel free to ask anything more specific if you have any doubt.

Viewing 1 replies (of 1 total)
  • The topic ‘Changing the template for posts’ is closed to new replies.