當(dāng)前位置:首頁>WordPress建站>WordPress開發(fā)>WordPress函數(shù):comments_template(獲取評論模板)

WordPress函數(shù):comments_template(獲取評論模板)

描述

加載評論模板。只能用于單篇 文章 或 頁面 來顯示評論,如果不是這些頁面,將沒辦法顯示。

用法

<?php comments_template( $file, $separate_comments ); ?> 

參數(shù)

$file
(字符串string) (可選) 要加載的文件

默認(rèn): /comments.php
$separate_comments
(布爾值boolean) (可選) 是否根據(jù)評論的類型劃分評論

默認(rèn): false

例子

默認(rèn)用法

<?php comments_template(); ?> 

另類的評論模板

在某些情況下,你希望以不同的方式來顯示你的評論,那么,你可以建立一個自定義的文件(例如 short-comments.php),并且通過下面的方式調(diào)用:

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

注釋

Uses global: (array) $comment List of comment objects for the current post

Uses: $wpdb

Uses: $id

Uses: $post

Uses: $withcomments Will not try to get the comments if the post has none.

所在文件

comments_template() 包含在 wp-includes/comment-template.php.

可用過濾器和動作

List of comment filters and actions

相關(guān)函數(shù)

comment_form()

get_header(), get_footer(), get_sidebar(), get_template_part(), get_search_form()

聲明:本站所有文章,如無特殊說明或標(biāo)注,均為本站原創(chuàng)發(fā)布。任何個人或組織,在未征得本站同意時,禁止復(fù)制、盜用、采集、發(fā)布本站內(nèi)容到任何網(wǎng)站、書籍等各類媒體平臺。如若本站內(nèi)容侵犯了原著者的合法權(quán)益,可聯(lián)系我們進(jìn)行處理。

給TA打賞
共{{data.count}}人
人已打賞
歡迎關(guān)注WordPress大學(xué)公眾號 WPDAXUE
WordPress開發(fā)

WordPress函數(shù):get_search_form(獲取搜索表單)

2013-4-5 7:35:00

WordPress開發(fā)

WordPress函數(shù):bloginfo(顯示博客信息)

2013-4-5 7:59:00

5 條回復(fù) A文章作者 M管理員
  1. 這評論是自帶的嗎?就是改了樣式?我都不知道comments.php要寫點(diǎn)什么鬼

  2. zhoushaofeijjz

    請問如何才能前臺顯示評論,然后能夠刪除評論的

  3. 測試代碼樣式
    (function() {
    "use strict";

    function inject(str)
    {
    var elem = document.createElement("script");

    elem.setAttribute("type", "application/javascript");
    elem.textContent = "(function() {\"use strict\"; (" + str + ")();})();";

    document.body.appendChild(elem);
    }

  4. 小白表示只看懂了一點(diǎn)點(diǎn)。

    • 測試,兩個字不能發(fā)送?

?
個人中心
購物車
優(yōu)惠劵
今日簽到
有新私信 私信列表
搜索

遂昌县| 册亨县| 佳木斯市| 祁东县| 裕民县| 苏尼特右旗| 逊克县| 合水县| 盘山县| 吉安县| 洛扎县| 鄂托克旗| 绥阳县| 布尔津县| 营口市| 蒲江县| 抚宁县| 望都县| 新绛县| 洪泽县| 柳州市| 保康县| 和田县| 翼城县| 赞皇县| 双峰县| 柞水县| 乐亭县| 霍林郭勒市| 霍山县| 崇阳县| 常熟市| 犍为县| 西青区| 琼海市| 鄂尔多斯市| 香格里拉县| 曲水县| 武陟县| 灌南县| 陕西省|