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
shaulhadar
447 Posts
shaulhadar posted this 30 April 2015

Wow Olivia, this is amazing, this means that like stagger lee wrote, we could use acf hooks straight inside themler!!!!

Thank you so much for that!!

Wow Olivia, this is amazing, this means that like stagger lee wrote, we could use acf hooks straight inside themler!!!! Thank you so much for that!!
Stagger Lee
1818 Posts
Stagger Lee posted this 30 April 2015

Exactly this, thank you,

Exactly this, thank you,
Support Team
Support Team posted this 30 April 2015

Hi,

Our developers discussed your request and decided to add new control similar to existing HTML control, which allows to execute custom php.
The final version of this control might look a little differently but here is it:

cms-code.png

Thank you,
Olivia

Hi, Our developers discussed your request and decided to add new control similar to existing HTML control, which allows to execute custom php. The final version of this control might look a little differently but here is it: !cms-code.png! Thank you, Olivia
Stagger Lee
1818 Posts
Stagger Lee posted this 29 April 2015

OK Aileen, thanks.

PHP code inside HTML blocks is something different. Cannot open more topics, only me write here at forum. Tend to be boring for other Users.

PHP code inside HTML blocks for, some examples:

  • Output of custom fields.
  • Putting shortcodes in theme via PHP.
  • I use my own PHP snippets to check if post has gallery, video, audio, oembed, attachments, etc. According to this I display small SVG icon in Blog list.
  • We could put call for a template file to reduce need for widgets. Littole special customization, but...See my theme here:
    http://answers.billiondigital.com/questions/10934/one-feature-that-would-make-themler-killer

  • We could output code of plugins where we want. Directly in template file to eliminate need for inserting shortcodes in editor. (one example review/Rating/voting stars in Blog and detailed view, or code for content views code.

It is basically only a fraction of things we could make if we could put PHP code in HTML blocks (Insert option).

Of course with some basic PHP validation check to prevent Themler show blank page and fatal errors. There is already validation inside Theme settings option, just reuse it,

OK Aileen, thanks. PHP code inside HTML blocks is something different. Cannot open more topics, only me write here at forum. Tend to be boring for other Users. PHP code inside HTML blocks for, some examples: - Output of custom fields. - Putting shortcodes in theme via PHP. - I use my own PHP snippets to check if post has gallery, video, audio, oembed, attachments, etc. According to this I display small SVG icon in Blog list. - We could put call for a template file to reduce need for widgets. Littole special customization, but...See my theme here: [http://answers.billiondigital.com/questions/10934/one-feature-that-would-make-themler-killer][1] [1]: http://answers.billiondigital.com/questions/10934/one-feature-that-would-make-themler-killer - We could output code of plugins where we want. Directly in template file to eliminate need for inserting shortcodes in editor. (one example review/Rating/voting stars in Blog and detailed view, or code for content views code. It is basically only a fraction of things we could make if we could put PHP code in HTML blocks (Insert option). Of course with some basic PHP validation check to prevent Themler show blank page and fatal errors. There is already validation inside Theme settings option, just reuse it,
Support Team
Support Team posted this 29 April 2015

Hello Stagger Lee,
I'm very sorry for the inconvenience, there is elaboration for my previous post regarding WP categories: In fact WP does not support custom templates for single posts in certain category (but not "different styles for different categories" as I wrote before).

As it would be possible to implement it in theme via custom PHP code the ability to add PHP under Theme Settings will be helpful.

Regards,
Aileen

Hello Stagger Lee, I'm very sorry for the inconvenience, there is elaboration for my previous post regarding WP categories: In fact WP does not support custom templates for single posts in certain category (but not "different styles for different categories" as I wrote before). As it would be possible to implement it in theme via custom PHP code the ability to add PHP under Theme Settings will be helpful. Regards, Aileen
shaulhadar
447 Posts
shaulhadar posted this 29 April 2015

I want the php in html as well! :)

I want the php in html as well! :)
Stagger Lee
1818 Posts
Stagger Lee posted this 28 April 2015

Thanks. Give us option to put PHP code inside HTML block, Text block.

Thanks. Give us option to put PHP code inside HTML block, Text block.
Support Team
Support Team posted this 28 April 2015

Hello Stagger Lee,
natively WP does not support different styles for different categories, so we suppose that it worth to implement this feature as custom control or via custom code. It is in our plans to add special field under Theme Settings that allows enter custom code for CMS. So it would be possible to add custom PHP code for WP.

Regards,
Aileen

Hello Stagger Lee, natively WP does not support different styles for different categories, so we suppose that it worth to implement this feature as custom control or via custom code. It is in our plans to add special field under Theme Settings that allows enter custom code for CMS. So it would be possible to add custom PHP code for WP. Regards, Aileen
Stagger Lee
1818 Posts
Stagger Lee posted this 23 April 2015

Worth noting, Themler will delete all your code inside theme functions.php on each Save inside Themler.
Search on Google how to put another functions.php inside a plugin. It is very easy. And work on it functions.php.

Worth noting, Themler will delete all your code inside theme functions.php on each Save inside Themler. Search on Google how to put another functions.php inside a plugin. It is very easy. And work on it functions.php.
You must log in or register to leave comments