Programatically assign a template to posts belonging to a given category

Posted in: Newspaper
Post count: 42

Hello,
I’m using Center Pro with Newspaper. I’d like to use a single post custom template only to posts belonging to a given category. What’s the best way to do it? Can I programatically assign a custom template only to some posts according with their category id? If not, which php file must I edit to change the template according with post category?

Post count: 21065

Hello!

You can have multiple post templates and assign them in the Newspaper -> Theme panel -> Categories: https://app.screencast.com/DmCZ5ZjP95JyP

Thank you!

Post count: 42

Thank you. What happens if a posts has 2 categories with different templates? Which one has been selected?

Post count: 21065

Hello!

It should take the primary category. But for this case, I recommend to access the article and assign the template manually like this: https://app.screencast.com/CVWDQCt4akRc4

Thank you!

Post count: 42

Thank you. I wonder what’s the best way to manage multiple category templates. I mean, if I have 3 or 4 category templates with minor changes and I want to modify something everywhere (i.e. the sidebar content), I must edit each template. Is there a sort of hierarchy of templates, with mother and children and cascading rules?

Post count: 21065

Hello!

No. You should edit every template as you like and assign it to your category. You have only one option to make the category template global, which will apply to all your categories. Then, for the special category, you should assign its own special template.

Thank you!

Viewing 6 posts - 1 through 6 (of 6 total)
The forum ‘Newspaper’ is closed to new topics and replies.