Advanced

Create Custom Templates for your KB

You can create custom templates to replace the Knowledge Base templates from Helpie WP plugin. There are current 4 main templates:

1. Main Page Template :

This is the archive page template of Helpie’s Custom Post Type. You can register a custom template for KB archive / main page by using the following code. You can use this code in your theme / child theme’s functions.php

function set_custom_helpie_mp_template($template)
{
  if ( is_post_type_archive( 'pauple_helpie') ) {
    $template = get_stylesheet_directory().'/mainpage-helpie.php';
  }
  return $template;
}

add_filter('template_include','set_custom_helpie_mp_template');

Here ‘mainpage-helpie.php’ is the name of the new template you are creating for the Main Page.

2. Category Page Template :

This is the category page template of Helpie’s Custom Post Type.

function set_custom_helpie_cat_template($template)
{
  if ( is_tax( 'helpdesk_category') ) {
    $template = get_stylesheet_directory().'/catpage-helpie.php';
  }
  return $template;
}
add_filter('template_include','set_custom_helpie_cat_template');

Here ‘catpage-helpie.php’ is the name of the new template you are creating for the Category Page.

3. Single Page Template:

This is the template used for the single article page in Helpie’s Knowledge Base.

function set_custom_helpie_single_template($template)
{
  if ( is_singular('pauple_helpie') ) 
  { 
    $template = get_stylesheet_directory().'/single-helpie.php';   
  }
    return $template;
}
add_filter('template_include','set_custom_helpie_single_template');


This condition checks for a single template of ‘pauple_helpie’ post type.
Here ‘single-pauple.php’ is the name of the new template you are creating for the Single Page.

Hooks

If you are to WordPress hooks and child theme customization, please take a look at these articles:

Single Post Title

adding a custom class to your single page post title by using helpie_kb_single_post_title filter, it’s useful if you want to style single page post title.

eg:

function callback_for_helpie_kb_single_post_title_filter( $classes )
{
   $custom_classes = array( 'ambitious-title' );
   return array_merge( $classes, $custom_classes );
}

add_filter( 'helpie_kb_single_post_title', 'callback_for_helpie_kb_single_post_title_filter' );

Single Post Content

adding a custom class to your single page post content by using helpie_kb_single_post_content filter. it’s useful if you want to style single page post content.

eg:

function callback_for_helpie_kb_single_post_content_filter( $classes )
{
  $custom_classes = array( 'ambitious-content');
  return array_merge( $classes, $custom_classes );
}

add_filter( 'helpie_kb_single_post_content', 'callback_for_helpie_kb_single_post_content_filter' );

 

Last updated byStephen
How did you like this article?0000

Leave a Reply

Your email address will not be published. Required fields are marked *