Template overrides allow you to customize the appearance and layout of ShahiAssist components without modifying the plugin core files. This ensures your changes survive plugin updates.
Understanding Plugin Templates
ShahiAssist uses template files located in includes/modules/*/views/ folders. These are PHP files that render the HTML output for various components like ticket forms, KB articles, and dashboards.
Template Hierarchy
- Plugin templates are loaded first.
- If a matching template exists in your theme’s
shahi-assist/folder, it overrides the plugin version. - This follows WordPress’s standard template override pattern.
- Knowledge Base:
includes/modules/knowledge-base/views/ - Ticketing:
includes/modules/ticketing-system/views/ - Admin views:
includes/admin/views/ - Create a folder
shahi-assistin your theme root. - Copy the desired template file(s) to this folder.
- Maintain the same subfolder structure if present.
- Modify HTML structure
- Add/remove CSS classes
- Include custom PHP logic
- Integrate with theme functions
single-article.php: Individual article displayarchive.php: Article listing pagesearch-results.php: Search results layoutsubmit-ticket.php: Ticket submission formview-ticket.php: Ticket detail viewticket-list.php: Ticket listingdashboard.php: Main dashboard layoutmy-tickets.php: User ticket list- Keep core functionality intact
- Use the same variable names and structures
- Test with different user roles
- Avoid heavy computations in templates
- Use caching for dynamic content
- Minimize database queries
- Track your custom templates in version control
- Document changes for future updates
- Consider using child themes for overrides
- Sanitize all output
- Validate user input
- Follow WordPress coding standards
- Check file permissions (755 for folders, 644 for files)
- Verify folder structure matches plugin
- Clear any caching plugins
- Hard refresh browser (Ctrl+F5)
- Check for syntax errors in PHP
- Ensure theme is active
- Test with default WordPress theme
- Check for JavaScript conflicts
- Review CSS specificity
How to Override Templates
Step 1: Locate the Template
Find the template you want to override in the plugin directory:
Step 2: Copy to Theme
Step 3: Customize
Edit the copied template file with your changes. You can:
Step 4: Test
Preview your changes and ensure functionality remains intact.
Common Template Overrides
Knowledge Base Templates
Ticket Templates
Dashboard Templates
Advanced Override Techniques
Using Filters for Dynamic Overrides
`php
addfilter(‘shahiassisttemplatepath’, function($path, $template) {
if ($template === ‘single-article.php’) {
return gettemplatedirectory() . ‘/custom-shahi-assist/single-article.php’;
}
return $path;
}, 10, 2);
`
Conditional Overrides
Override templates based on conditions:
`php
addfilter(‘templateinclude’, function($template) {
if (issingular(‘kbarticle’) && isuserlogged_in()) {
$customtemplate = gettemplate_directory() . ‘/shahi-assist/single-article-logged-in.php’;
if (fileexists($customtemplate)) {
return $custom_template;
}
}
return $template;
});
`
Best Practices
Maintain Compatibility
Performance Considerations
Version Control
Security
Troubleshooting
Template Not Loading
Changes Not Appearing
Conflicts with Theme
Examples
Custom KB Article Template
`php
`
Modified Ticket Form
`php
`
Resources
Share this article
Still need help?
Our support team is ready to assist you with personalized guidance for your workspace.