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

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

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.