Skip Navigation

[Resolved] Post template

This support ticket is created 7 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 -
- 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 3 replies, has 2 voices.

Last updated by Noman 7 years, 3 months ago.

Assisted by: Noman.

Author
Posts
#563155

Anonymous

Hi, can I use toolset to edit the default posts template of my theme?

#563195

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Simone,

Thank you for contacting Toolset support. Do you refer to Content Templates when you mention “can I use toolset to edit the default posts template of my theme?”

You can create Content Templates under Views > Content templates.

You can style them with HTML and CSS, and add the content you want using the Types and Views short codes
https://toolset.com/documentation/user-guides/view-templates/

You can then either assign that Content template to all Posts, by setting "posts" in the "Usage" section of the Content Template,
or, you can use this Content Template on a single Post Only by assigning it directly from within the Post Edit Screen in the right side Widget Area to your single Post /page

Please let me know if you have further questions regarding the issue mentioned in this Thread
and let me know if the above solution works for you.

Thank you

#563199

Anonymous

Is it possible to creare a content template just or posts belonging to a specific category?

#563350

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

If you want to apply different Content Templates created with Views >> for Posts of the different Categories. Then you can use this code to apply different Content Templates to each category’s posts:

function update_my_ct( $post_id ) {

	$ct_one = 3847;//replace 3847 with the Content template ID
	$ct_two = 3297;//replace 3297 with the Content template ID

	if (has_term( 'bcs', 'student-class', $post_id )){
		update_post_meta($post_id, '_views_template', $ct_one);     
	}
	elseif (has_term( 'mcs', 'student-class', $post_id )) {
		update_post_meta($post_id, '_views_template', $ct_two);  
	}
}
add_action( 'wp_insert_post', 'update_my_ct', 10 );

==> Please note comments in above code to change your Content Template IDs.
==> Whereas ‘bcs’ and ‘mcs’ will be replaced with your categories slugs.

While creating these Content Templates in Views, do not apply them anywhere (under “Usage” section), since we will apply them through above code. You can copy the above code for multiple terms / categories.

Related ticket & code, in case you want to apply it on the Posts created with CRED form, and each Category has its own Content Template applied to it:
https://toolset.com/forums/topic/set-default-content-template-for-posts-in-specific-category/#post-334400

Thanks