Custom posts template for specific category

Posted in: Newspaper
Post count: 10

Hi everyone,
Is there a way to use custom post template for specific post category?

I did like this:
Created function in functions.php which gets post slug and tries to find file single-{slug}.php.
If such file exists it uses it for template.

As in Newspaper theme post templates are not formed in usual way (as default WordPress does) I cannot find the right code to paste in single-{slug}.php. I just need it to work correctly like loop-single.php template.

I see, that template is formed from header->header-style->loop-single files. But when I try to combine the code inside single-{slug}.php it breaks the layout.

Of course I can keep searching for bugs and finally fix them, but maybe it is some other … more easy way to make it work.
I don’t know if it matters, I’m using childtheme.

Thank in advance.

Post count: 1291

Hi,

There’s a condition in single.php which loads the default style or if a style is set it loads one of the single_template files – http://screencast.com/t/jGGbVQqC
You can modify the code and add a new condition which checks on current post category/id/slug and uses a certain template.

Thank you, Emil G.

Post count: 10

Emil,
Thank a lot. I will try it.

Post count: 5

Hi Shuriken,

I have no idea how to program in php, but I’m really interested in this feature.
Could you please post your modification?
thanks!

Post count: 10

Hi, I can send you child-theme folder from that project, but I’m afraid it will not help you much. I’ve hardcoded a lot of modifications there (it means, that these modifications will break the theme if used on other site). So you sure will need decent php skills to use it for your site.

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