Category
To define a custom template (archive-my-category.html) for a given category (slug my-category):
//In your WP-AppKit theme's functions.js App.filter( 'template', function( template, current_screen ) { if ( TemplateTags.isCategory( 'my-category', current_screen ) ) { template = 'archive-my-category'; //Don't need .html here. } return template; } );
Custom Post Type
To define a custom single template (single-my-post-type.html) for a given post type (post type’s slug: my-post-type):
App.filter( 'template', function( template, current_screen ) { //Check the screen's post type with "TemplateTags.isPostType()" : //as we have to pass the current_screen as 3rd argument, we pass an empty post_id=0 as 2nd argument //( because we don't have to check a specific post ID here, just the post type 'my-post-type' ): if ( TemplateTags.isPostType( 'my-post-type', 0, current_screen ) ) { template = 'single-my-post-type'; //Don't need .html here. } return template; } );
And to define a custom archive template (archive-my-post-type.html) for the same post type (my-post-type):
App.filter( 'template', function( template, current_screen ) { if ( current_screen.screen_type === 'list' ) { if ( current_screen.data.query.post_type === 'my-post-type' ) { template = 'archive-my-post-type'; } } return template; } );
Component
To define a custom template (my-template.html) for a given component (component’s slug = “my-component-slug”)
App.filter( 'template', function( template, current_screen ) { if ( current_screen.component_id === 'my-component-slug' ) { template = 'my-template'; } return template; } );
To Know More
Here is the doc about:
How to add category title in single.html page?
Hi, you should find what you’re looking for in those tutorials:
– https://uncategorized-creations.com/3191/custom-post-data/.
– https://uncategorized-creations.com/1712/display-wordpress-custom-fields-app/ (see the “Taxonomy Terms” section)
In a nutshell, you will add your category title as an additional post data using the “wpak_post_data” filter, then use it in your single.html template as any other post data (something like <%= post.my_category_title %>).
Hope this helps.