欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

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

comments_template()(獲取評論模板)

comments_template() 函數(shù)用來獲取評論模板,一般只能用在文章或者頁面上,如果不是文章或者頁面將無法顯示。
用法

comments_template( $file, $separate_comments );

參數(shù)

$file

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

默認值:/comments.php(當前主題根目錄的 comments.php 文件)。

$separate_comments

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

默認值:False

返回值

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

例子

默認引入當前主題根目錄的 comments.php 文件。

<?php comments_template(); ?>

引入自定義文件:

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

其它

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


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

用法

get_search_form( $echo );

參數(shù)

$echo

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

默認值:True

返回值

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

例子

如果主題根目錄沒有 searchform.php 文件,則默認為下邊的表單代碼:

<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)文章

最新評論