comments_template()(获取评论模板)
comments_template() 函数用来获取评论模板,普通只能用在文章或许页面上,假如不是文章或许页面将无奈显示。
用法
comments_template( $file, $separate_comments );
参数
$file
(字符串)(可选)要评论模板文件。
默许值:/comments.php(以后主题根目录的 comments.php 文件)。
$separate_comments
(布尔)(可选)能否依据评论的类型区分评论。
默许值:False
前往值
此函数无前往值。
例子
默许引入以后主题根目录的 comments.php 文件。
<?php comments_template(); ?>
引入自定义文件:
<?php comments_template( '/short-comments.php' ); ?>
其它
此函数位于:wp-includes/comment-template.php
get_search_form()(获取搜寻表单)
get_search_form() 函数用来获取搜寻表单,搜寻表单的代码位于以后主题根目录的 searchform.php 文件。
用法
get_search_form( $echo );
参数
$echo
(布尔)(可选)假如为真则间接打印搜寻表单,假如不为真则前往搜寻表单的代码。
默许值:True
前往值
(string)假如 $echo 参数为 False,则前往搜寻表单的 Html 代码。
例子
假如主题根目录没有 searchform.php 文件,则默许为下边的表单代码:
<form role="search" method="get" id="searchform" class="searchform" action="<?php esc_url( home_url( '/' )); ?>">
<p>
<label class="screen-reader-text" for="s"><?php _x( 'Search for:', 'label' ); ?></label>
<input type="text" value="<?php get_search_query(); ?>" name="s" id="s" />
<input type="submit" id="searchsubmit" value="<?php esc_attr_x( 'Search', 'submit button' ); ?>" />
</p>
</form>
其它
此函数位于:wp-includes/general-template.php
以上就是安达网络工作室关于《讲解WordPress中用于获取评论模板和搜索表单的PHP函数》的一些看法。更多内容请查看本栏目更多内容!
同get_post_meta()一样,用于前往文章的自定义字段值得一个函数,只不过get_post_custom()函数应用起来更简...
本文实例讲述了WordPress给文章图片主动增加链接的办法。分享给大家供大家参考。详细剖析如下: 咱们会看到...
一、成绩形容 1、19号手动晋级到wordpress4.1,21号早上7点看网站php探针,发现零碎负载过高,差不多在1到1...
函数is_singular()检测后果为true,当上面其一前往true时:is_single()、is_page()、is_attachment()。 假如...
header_image() header_image() 函数是 WordPress 自定顶部图像的规范接口函数,该函数能够主动判别后盾设置...
效劳器钱用光了要关了或许是效劳器想要搬家,需求备份各种数据。 明天简略的备份了一下在效劳器下面wordpre...