Explain the PHP functions used to get Comment templates and search forms in WordPress

Source: Internet
Author: User
Comments_template () (Get comment template)

The Comments_template () function is used to get a comment template, which can only be used on articles or pages, if not articles or pages that cannot be displayed.
Usage

Comments_template ($file, $separate _comments);

Parameters

$file

(string) (optional) to comment on the template file.

Default value:/comments.php (the comments.php file for the current topic root).

$separate _comments

(Boolean) (optional) whether to differentiate comments based on the type of comment.

Default value: False

return value

There is no return value for this function.

Example

The default comments.php file that introduces the root of the current theme.

<?php comments_template ();?>

To introduce a custom file:

<?php comments_template ('/short-comments.php ');?>

Other

This function is located at: wp-includes/comment-template.php


Get_search_form () (Get search form)
The Get_search_form () function is used to get the search form, and the code for the search form is located in the searchform.php file of the current topic root directory.

Usage

Get_search_form ($echo);

Parameters

$echo

(Boolean) (optional) If true, print the search form directly, or return the code for the search form if it is not true.

Default value: True

return value

(string) If the $echo argument is False, returns the Html code for the search form.

Example

If the theme root directory does not have a searchform.php file, the default is the form code below:

Other

This function is located at: wp-includes/general-template.php

The above describes the WordPress used to get comment templates and search form PHP functions, including aspects of the content, I hope to be interested in PHP tutorial friends helpful.

  • 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.