Style / Edit post display template in Themler per category basis

Stagger Lee
1818 Posts
Stagger Lee posted this 23 April 2015

Theme functions.php or functions.php inside a plugin:
my-category = name of your category where you want detailed post view styled differently.

function get_custom_cat_template($single_template) {
global $post;
if ( in_category( 'my-category' )) {
$single_template = TEMPLATEPATH . '/single-my-category.php';
}
return $single_template;
}
add_filter( "single_template", "get_custom_cat_template" ) ;

If Themler gives you some boring page to style just right click on menus and "Open link" until you get to your post in specific category, then you can style it.

Name custom template in Themler similar to this example adapted to your category slug: single-my-category.php

Theme functions.php or functions.php inside a plugin: **my-category** = name of your category where you want detailed post view styled differently. function get_custom_cat_template($single_template) { global $post; if ( in_category( 'my-category' )) { $single_template = TEMPLATEPATH . '/single-my-category.php'; } return $single_template; } add_filter( "single_template", "get_custom_cat_template" ) ; If Themler gives you some boring page to style just right click on menus and "Open link" until you get to your post in specific category, then you can style it. Name custom template in Themler similar to this example adapted to your category slug: **single-my-category.php**
Vote to pay developers attention to this features or issue.
29 Comments
Order By: Standard | Newest
Stagger Lee
1818 Posts
Stagger Lee posted this 05 August 2015

No. it is something like this:

  • You have one category "Cars"
  • You have another category "Bicycles".
  • This snippet gives you chance to make custom "Post detailed view" templates and have separate styled templates for Cars and Bicycles.

No. it is something like this: - You have one category "Cars" - You have another category "Bicycles". - This snippet gives you chance to make custom "Post detailed view" templates and have separate styled templates for Cars and Bicycles.
joshpell
31 Posts
joshpell posted this 21 September 2016

In regards to the original post there is under appearance --> editor a php file called functions-additional.php that you can write custom functions into and they will not be overwritten when you update your theme, this is how I just many of the functions for woocommerce.

In regards to the original post there is under **appearance --> editor** a php file called **functions-additional.php** that you can write custom functions into and they will not be overwritten when you update your theme, this is how I just many of the functions for woocommerce.
Support Team
Support Team posted this 23 September 2016

Hello Josh,
thank you for suggestion. It's pretty useful and I'll add it to our wish list

regards,
Aileen

Hello Josh, thank you for suggestion. It's pretty useful and I'll add it to our wish list regards, Aileen
joshpell
31 Posts
joshpell posted this 29 September 2016

Update on my previous comment, you can work on the theme and publish it without it affecting your functions-additional.php HOWEVER if you upgrade your theme all custom functions that you have written will be overwritten so make sure you have a backup of all your custom functions before you update to a new themler version.

Update on my previous comment, you can work on the theme and publish it without it affecting your functions-additional.php **HOWEVER** if you upgrade your theme all custom functions that you have written will be overwritten so make sure you have a backup of all your custom functions before you update to a new themler version.
Support Team
Support Team posted this 03 October 2016

Hi,

You can add custom functions to this file in directly Themler >> Home tab >> Settings >> CMS code. This will help to keep the custom code.

Thank you,
Olivia

Hi, You can add custom functions to this file in directly Themler >> Home tab >> Settings >> CMS code. This will help to keep the custom code. Thank you, Olivia
joshpell
31 Posts
joshpell posted this 04 October 2016

You can also use the plugin
https://wordpress.org/plugins/my-custom-functions/
Works great if your worried about loosing your custom functions.

You can also use the plugin https://wordpress.org/plugins/my-custom-functions/ Works great if your worried about loosing your custom functions.
Samuele
13 Posts
Samuele posted this 26 February 2018

Hi,

I followed up the instruction above and I managed to change the blog-view template for a specific category... my problem is that the change is then reflected on the single post template. To be more specific the layout for my blog-view template is set in two columns, and this is fine, then when I click to open one of the post also the layout of the post is in two column and therefore my content occupy only half of the space available on screen.

I would like to custom only the post-view for all the post that belongs to a specific category without affecting the blog layout. Is this possible?

I did also try to create from within Themler a new post-template instead of a new Custom-Template, but by doing this I get php error whenever I try to open a post. I get the following error:

include (my_path) failed to open the stream: No such file or directory on (my-path) on line 74.
include(): Failed opening 'my-path....single-post-news.php' for inclusion (include_path='.:/usr/lib/php7.0') in /my-path/wp-includes/template-loader.php on line 74

Anybody out there that can help?

Thanks a lot
Samuele

Hi, I followed up the instruction above and I managed to change the blog-view template for a specific category... my problem is that the change is then reflected on the single post template. To be more specific the layout for my blog-view template is set in two columns, and this is fine, then when I click to open one of the post also the layout of the post is in two column and therefore my content occupy only half of the space available on screen. I would like to custom only the post-view for all the post that belongs to a specific category without affecting the blog layout. Is this possible? I did also try to create from within Themler a new post-template instead of a new Custom-Template, but by doing this I get php error whenever I try to open a post. I get the following error: include (my_path) failed to open the stream: No such file or directory on (my-path) on line 74. include(): Failed opening 'my-path....single-post-news.php' for inclusion (include_path='.:/usr/lib/php7.0') in /my-path/wp-includes/template-loader.php on line 74 Anybody out there that can help? Thanks a lot Samuele
phoumanaphensisanavong
1 Posts
phoumanaphensisanavong posted this 11 July 2018

hello, I am interesting this method.
Can you please post the Link for example or link for video present

Thank you,
Phoumana

hello, I am interesting this method. Can you please post the Link for example or link for video present Thank you, Phoumana
Support Team
Support Team posted this 11 July 2018

Hello,

Do you mean cusomizing post view in Post and Blog templates separately? For this please select Posts tab >> Customize template style.

Sincerely,
Nettie,
BillionDigital Team

Hello, Do you mean cusomizing post view in Post and Blog templates separately? For this please select Posts tab >> Customize template style. Sincerely, Nettie, BillionDigital Team
You must log in or register to leave comments