The following describes the PHP functions used in WordPress to obtain comment templates and search forms, wordpressphp. Explains the PHP function used to get the comment template and search form in WordPress. the wordpressphpcomments_template () (get the comment template) comments_template () function is used to get the comment template, describes the PHP functions used in WordPress to obtain comment templates and search forms, wordpressphp
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
Articles you may be interested in:
- Get the header template and the bottom template in WordPress topic writing
- How to introduce a template file for WordPress topic creation
Comment comments_template () (get the comment template) the comments_template () function is used to get the comment Template ,...