Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to get comment template and search form in WordPress

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

Xiaobian to share with you how to get comment templates and search forms in WordPress, I hope you have something to gain after reading this article, let's discuss it together!

comments_template()

comments_template() function is used to get comments template, generally can only be used in articles or pages, if not articles or pages will not be displayed.

usage

comments_template( $file, $separate_comments );

parameters

$file

(String)(Optional) To comment on the template file.

Default: /comments.php (comments.php file in the root directory of the current topic).

$separate_comments

(Boolean)(Optional) Whether to differentiate reviews based on their type.

Default: False

return value

This function has no return value.

example

By default, the comments.php file is introduced into the root directory of the current topic.

Introducing custom files:

other

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

get_search_form()

The get_search_form() function is used to get the search form whose 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 prints the search form directly, if not true returns the search form code.

Default: True

return value

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

example

If there is no searchform.php file in the topic root directory, the default is the following form code:

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report