亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

講解WordPress中用于獲取評(píng)論模板和搜索表單的PHP函數(shù)

 更新時(shí)間:2015年12月28日 14:30:16   作者:斌果  
這篇文章主要介紹了WordPress中用于獲取評(píng)論模板和搜索表單的PHP函數(shù),需要的朋友可以參考下

comments_template()(獲取評(píng)論模板)

comments_template() 函數(shù)用來(lái)獲取評(píng)論模板,一般只能用在文章或者頁(yè)面上,如果不是文章或者頁(yè)面將無(wú)法顯示。
用法

comments_template( $file, $separate_comments );

參數(shù)

$file

(字符串)(可選)要評(píng)論模板文件。

默認(rèn)值:/comments.php(當(dāng)前主題根目錄的 comments.php 文件)。

$separate_comments

(布爾)(可選)是否根據(jù)評(píng)論的類型區(qū)分評(píng)論。

默認(rèn)值:False

返回值

此函數(shù)無(wú)返回值。

例子

默認(rèn)引入當(dāng)前主題根目錄的 comments.php 文件。

<?php comments_template(); ?>

引入自定義文件:

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

其它

此函數(shù)位于:wp-includes/comment-template.php


get_search_form()(獲取搜索表單)
get_search_form() 函數(shù)用來(lái)獲取搜索表單,搜索表單的代碼位于當(dāng)前主題根目錄的 searchform.php 文件。

用法

get_search_form( $echo );

參數(shù)

$echo

(布爾)(可選)如果為真則直接打印搜索表單,如果不為真則返回搜索表單的代碼。

默認(rèn)值:True

返回值

(string)如果 $echo 參數(shù)為 False,則返回搜索表單的 Html 代碼。

例子

如果主題根目錄沒(méi)有 searchform.php 文件,則默認(rèn)為下邊的表單代碼:

<form role="search" method="get" id="searchform" class="searchform" action="<?php esc_url( home_url( '/' )); ?>">
  <div>
    <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' ); ?>" />
  </div>
</form>

其它

此函數(shù)位于:wp-includes/general-template.php

相關(guān)文章

最新評(píng)論