Forum

Thread tagged as: Question, Problem, Blog

Create two 'post' templates

I need a post template for the 'blog' posts section on my site and another for the 'news' posts section.

Question is how do I set this up? at the moment I have a post.php page in a /posts/ folder which is the blog post template.

But what is telling the CMS to look in /posts/post.php for the template for all posts no matter what section they're in?

Andrew Areoff

Andrew Areoff 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

The CMS just looks for the posts folder - nothing 'tells' it so as such.

Are your post types not showing up?

Post types?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, you said you needed two different types of post - one for news and one for blog.

Have you created posts/news.php for example?

I've just added a news.php file for the news post but it has no effect.

What command calls this file to be used on news posts?

You can choose the post type "news" from the post edit page (when adding a new post). There's a dropdown choice normally below the Allow Comments checkbox.

Clive Walker said:

You can choose the post type "news" from the post edit page (when adding a new post). There's a dropdown choice normally below the Allow Comments checkbox.

I don't get that option Clive.

It might be that the option only appears when you have something in the specific template folder. That is, alternative templates in perch/templates/blog/posts.

For example, you would need to add a news.html template there. This template provides the alternative fields for your News post type. It could be similar to the post.html template of course.

Is that what you want to do? Choose a different post type for News and for Blog as you create a post?

Clive Walker said:

It might be that the option only appears when you have something in the specific template folder. That is, alternative templates in perch/templates/blog/posts.

For example, you would need to add a news.html template there. This template provides the alternative fields for your News post type. It could be similar to the post.html template of course.

Is that what you want to do? Choose a different post type for News and for Blog as you create a post?

I've tried that as well. I've put a news.html in the Perch folder /blog/templates/

Drew did say to put a news.php file in the /posts/ folder (that's where my blog post template lives. but that's not having any effect either.

The news.html template needs to be in perch/templates/blog/posts folder. I'm not entirely sure where you have put it.

Clive Walker said:

The news.html template needs to be in perch/templates/blog/posts folder. I'm not entirely sure where you have put it.

This is where it is located.

The default post.html is in the folder above: /templates/blog/

That all sounds OK. In which case, I don't understand why you cannot see the Post type dropdown choice under Allow Comments when you add a post.

Clive Walker said:

That all sounds OK. In which case, I don't understand why you cannot see the Post type dropdown choice under Allow Comments when you add a post.

I don't understand either. A job for another day I think.