Describes the PHP functions used in WordPress to obtain comment templates and search forms.

Source: Internet
Author: User
: 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.