apply_filters( 'comments_template', string $theme_template )
Filters the path to the theme template file used for the comments template.
Parameters Parameters
- $theme_template
-
(string) The path to the theme template file.
More Information More Information
The comments_template
filter can be used to load a custom template form a plugin which replaces the theme’s default comment template.
Source Source
Changelog Changelog
Version | Description |
---|---|
1.5.1 | Introduced. |
User Contributed Notes User Contributed Notes
You must log in before being able to contribute a note or feedback.
Code example migrated from Codex:
A plugin can register as a content filter with the code:
Where
my_plugin_comment_template
is the function WordPress should call when thecomment_template()
function is called on the theme. Note that the filter function the plugin defines must return the a full path to a template file or the resulting page will be blank.This is an example of loading a different comments template for a custom post type:
Expand full source codeCollapse full source code
The example code will load the template file
reviews.php
located in your plugins folder for CPT calledbusiness
; otherwise, the code uses default template.