WordPress主題開發:無評論不顯示評論框

    記錄一次錯誤。

    函數官方參考:

    https://codex.wordpress.org/Function_Reference/have_comments

    開發評論模板時遇到一個問題,當博文有評論時,一切正常,

    WordPress主題開發:無評論不顯示評論框

    當博文無評論時,評論框不顯示。

    WordPress主題開發:無評論不顯示評論框

    原因:

    是判斷函數:have_comments()的問題

    我在代碼中是這樣寫的:

     if ( have_comments() ) : ?>
    ?
    
    
    ????
    
    
    ???? comment_form(array(
    ????
            'comment_notes_after' => '
    請訪問我們的 隱私政策 頁面。
    ',
    ????????'title_reply'=>'添加新評論',
    ????//評論輸入框上方文字
    ????????'comment_notes_before'=>'
    ' . __( '' ) . ( $req ? $required_text : '' ) . '
    ',
    ????//評論輸入框
    ???? ???'comment_field' => '
    ' . _x( '', 'noun' ) . '
    ',
    ???? 
    
    ????
    ????????'label_submit'=>__( '提交評論' ),
    ????//強制登陸留言
    ????????'must_log_in'=>'
    ' .  sprintf( __( '您必須e登陸 才能留言.' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( ) ) ) ) . '
    ',
    ????//登陸為
    ????????'logged_in_as'=>'
    ' . sprintf( __( '當前身份為:%2$s,您需要退出嗎?' ), admin_url( 'profile.php' ), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( ) ) ) ) . '
    ',
        ));
    ????
    ?>
    ????
    ????<h2 class="comments-title">
                    printf( _nx( '一個想法 "%2$s"', '"%2$s"共有 %1$s 條評論  ', get_comments_number(), '注釋標題', 'mirages' ),
                        number_format_i18n( get_comments_number() ), '' . get_the_title() . '' );
                ?>h2><ol class="comment-list">
                    wp_list_comments( array(
                        'style'       => 'ol',
                        'short_ping'  => true,
                        'avatar_size' => 120,//頭像大小
    ????????????????????'reply_text'  =>'回復',/*回復文字*/
    ????????????????????'callback' => 'mirages_comment'/*使用自定義回調函數控制評論的外觀*/
                    ) );
                ?>ol>
    ????
    
    ????<div class="pagination"> paginate_comments_links(); ?>
    div>
    ????
    ????
     // Are there comments to navigate through?
    ????????????//是否有可瀏覽的注釋?if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) :
            ?> endif; // Check for comment navigation(檢查注釋導航) ?>
    ????
      if ( ! comments_open() && get_comments_number() ) : ?><p class="no-comments"> _e( '評論已關閉.' , 'mirages' ); ?>p> endif; ?>
    
    
         endif; // have_comments() ?>
    ?
    
    

    當博文中無評論時,函數判斷為假,函數判斷中的內容不顯示。

    當博文中有評論時,函數判斷為真,顯示判斷中的內容。

    在此處,這個函數是用來控制評論中的博文標題是否顯示的,而我卻在其中把評論框也包進去了。

    應該是這樣寫:

     if ( have_comments() ) : ?>
    	<h2 class="comments-title">
                    printf( _nx( '一個想法 "%2$s"', '"%2$s"共有 %1$s 條評論  ', get_comments_number(), '注釋標題', 'mirages' ),
                        number_format_i18n( get_comments_number() ), '' . get_the_title() . '' );
                ?>h2>
    	 endif; // end have_comments() ?>
    
    VUE模塊

    在項目中使用依賴 - Vite

    2022-9-12 15:21:37

    網站

    WebStack Laravel - 網址導航網站項目

    2019-6-16 15:31:58

    ??
    Npcink上的部份代碼及教程來源于互聯網,僅供網友學習交流,若您喜歡本文可附上原文鏈接隨意轉載。
    無意侵害您的權益,請發送郵件至 1355471563#qq.com 或點擊右側 私信:Muze 反饋,我們將盡快處理。
    0 條回復 A文章作者 M管理員
      暫無討論,說說你的看法吧
    ?
    個人中心
    購物車
    優惠劵
    今日簽到
    有新私信 私信列表
    搜索
    主站蜘蛛池模板: 日本激情一区二区三区| 呦系列视频一区二区三区| 精品人妻少妇一区二区三区不卡| 天堂va视频一区二区| 亚洲熟妇av一区二区三区下载| 琪琪see色原网一区二区| 日韩免费一区二区三区在线 | 精品免费国产一区二区三区| 老熟妇仑乱视频一区二区| 久久精品无码一区二区三区 | 亚洲熟妇无码一区二区三区 | 国产成人精品一区二三区 | 国模精品一区二区三区视频 | 亚洲无人区一区二区三区| 福利一区二区三区视频午夜观看| 午夜AV内射一区二区三区红桃视| 99无码人妻一区二区三区免费| 精品一区二区三区自拍图片区| 精品久久一区二区| 无码日韩精品一区二区免费暖暖| 久久se精品一区二区| 无码国产精成人午夜视频一区二区 | 一本久久精品一区二区| 中文字幕人妻第一区| 99久久无码一区人妻a黑| 日韩电影一区二区| 亚洲国产老鸭窝一区二区三区| 性无码一区二区三区在线观看| 国产激情视频一区二区三区| 中文字幕精品一区二区三区视频| 国产区精品一区二区不卡中文| 久久91精品国产一区二区| 精品一区精品二区制服| 成人丝袜激情一区二区| 无码人妻精品一区二区蜜桃百度 | 久久久国产精品无码一区二区三区| 中文字幕在线不卡一区二区| 国产一区二区三区免费看 | 老鸭窝毛片一区二区三区| 久久国产香蕉一区精品 | 久久99国产一区二区三区|