我需要对WORDPRESS评论区进行一些自定义,因此我在我的子主题中使用了以下代码:
<div id="comments" class="x-comments-area">
<?php if ( have_comments() ) : ?>
<?php
//The author of current post
$author_ID = get_the_author_meta("ID");
//The current post ID
$p_ID = get_the_ID();
?>
<h2 class="h-comments-title"><span><?php _e( \'Comments\' , \'__x__\' ); ?> <small>
<?php
//Number of guest comments
echo ztjalali_persian_num(number_format_i18n(count(get_comments(array(\'post_id\' => $p_ID,\'author__not_in\' => array($author_ID))))));
?></small></span></h2>
<ol class="x-comments-list">
<?php
wp_list_comments( array(
\'callback\' => \'x_icon_comment\',
\'style\' => \'ol\'
) );
?>
</ol>
<?php if ( get_comment_pages_count() > 1 && get_option( \'page_comments\' ) ) : ?>
<nav id="comment-nav-below" class="navigation" role="navigation">
<h1 class="visually-hidden"><?php _e( \'Comment navigation\', \'__x__\' ); ?></h1>
<div class="nav-previous"><?php previous_comments_link( __( \'← Older Comments\', \'__x__\' ) ); ?></div>
<div class="nav-next"><?php next_comments_link( __( \'Newer Comments →\', \'__x__\' ) ); ?></div>
</nav>
<?php endif; ?>
<?php if ( ! comments_open() && get_comments_number() ) : ?>
<p class="nocomments"><?php _e( \'Comments are closed.\' , \'__x__\' ); ?></p>
<?php endif; ?>
<?php endif; ?>
<?php
//Loading of smilies
ob_start(); cs_print_smilies(); $cs_print_smilies = ob_get_clean();
//Comment form re-arrangement
comment_form( array(
\'comment_notes_before\' => \'\',
\'comment_notes_after\' => \'\',
\'id_submit\' => \'entry-comment-submit\',
\'label_submit\' => __( \'Submit\' , \'__x__\' ),
\'title_reply\' => __( \'<span>Leave a Comment</span>\' , \'__x__\' ),
\'fields\' => array(
\'author\' =>
\'<p class="comment-form-author">\' .
\'<input id="author" name="author" type="text" value="\' . get_comment_author() . \'" placeholder="\' . __( \'Name *\', \'__x__\' ) . \' \' . \'" size="30"/>\' .
\'</p>\',
\'email\' =>
\'<p class="comment-form-email">\' .
\'<input id="email" name="email" type="email" aria-required="true" aria-invalid="false" value="\' .get_comment_author_email() . \'" placeholder="\' . __( \'Email *\', \'__x__\' ) . \' \' . \'" size="30"/>\' .
\'</p>\',
\'url\' =>
\'<p class="comment-form-url">\' .
\'<input id="url" name="url" type="text" value="\' . get_comment_author_url() . \'" placeholder="\' . __( \'URL\', \'__x__\' ) . \'" size="30" />\' .
\'</p>\'
),
\'comment_field\' => \'<p class="comment-form-comment">\' .
\'</br>\'.
$cs_print_smilies .
\'<textarea id="comment" name="comment" cols="45" rows="4" placeholder="\' . _x( \'Comment *\', \'noun\', \'__x__\' ) . \'" aria-required="true"></textarea>\' .
\'</p>\'
) );
?>
</div>
但通过使用上述代码,我将在我发布的帖子中的评论区上方发布这些PHP通知:
Notice: Trying to get property of non-object in /home/foo/public_html/wp-includes/comment-template.php on line 28
Notice: Trying to get property of non-object in /home/foo/public_html/wp-includes/comment-template.php on line 46
Notice: Trying to get property of non-object in /home/foo/public_html/wp-includes/comment-template.php on line 97
Notice: Trying to get property of non-object in /home/foo/public_html/wp-includes/comment-template.php on line 97
Notice: Trying to get property of non-object in /home/foo/public_html/wp-includes/comment-template.php on line 296
Notice: Trying to get property of non-object in /home/foo/public_html/wp-includes/comment-template.php on line 296
Notice: Trying to get property of non-object in /home/foo/public_html/wp-includes/comment-template.php on line 309
虽然我知道问题不在评论模板内。php文件。
我怎样才能摆脱它们?