: This article describes the PHP functions used to obtain comment templates and search forms in WordPress. For more information about PHP tutorials, see. Comments_template () (get Comment template)
The comments_template () function is used to obtain the comment template. it can only be used on articles or pages. it cannot be displayed if it is not an article or page.
Usage
comments_template( $file, $separate_comments );
Parameters
$ File
(String) (optional) comment on the template file.
Default value:/comments. php (the comments. php file in the root directory of the current topic ).
$ Separate_comments
(Boolean) (optional) whether to distinguish between comments based on the comment type.
Default value: False
Return value
This function has no return value.
Example
The comments. php file in the root directory of the current topic is introduced by default.
<?php comments_template(); ?>
Introduce a custom file:
<?php comments_template( '/short-comments.php' ); ?>
Others
This function is located in: wp-des/comment-template.php
Get_search_form () (obtain the search form)
The get_search_form () function is used to obtain the search form. the search form code is located in the searchform. php file in the root directory of the current topic.
Usage
get_search_form( $echo );
Parameters
$ Echo
(Boolean) (optional) if true, the search form is printed directly. if not true, the code of the search form is returned.
Default value: True
Return value
(String) if the $ echo parameter is False, the Html code of the search form is returned.
Example
If the root directory of the topic does not contain the searchform. php file, the following form code is used by default:
Others
This function is located in: wp-des/general-template.php
The above describes the PHP functions used in WordPress to obtain comment templates and search forms, including some content, and hope to help those who are interested in PHP tutorials.