【发布时间】:2014-05-13 23:31:47
【问题描述】:
我一直在从头开始开发自定义 wordpress 主题,但在我的 cmets.php 文件中遇到了一个小问题。
https://gist.github.com/phillipdews/dcebfec2016a93bd0169
我认为问题源于该文件的第 44 行,因为当我尝试在我的博客文章上发表评论时,无论是否登录,评论过程都通过以下方式处理:
www.mydomain.com/postlink/wp-comments-post.php
当它自然需要去时:
www.mydomain.com/wp-comments-post.php
更新
这就是我决定要做的!我从头开始重新编写了 cmets.php 文件,如下所示:
<div id="comments">
<?php if ( post_password_required() ) : ?>
<p>This post is password protected. Enter the password to view and comments</p>
</div>
<?php
return;
endif;
?>
<?php if ( have_comments() ) : ?>
<ol>
<?php wp_list_comments ( array( 'callback' => 'BRUM_Theme_comment') ); ?>
</ol>
<?php
elseif ( ! comments_open() && ! is_page() && post_type_supports( get_post_type(), 'comments' ) ) :
?>
<p>Comments are closed</p>
<?php endif; ?>
<?php comment_form(); ?>
</div>
然后我将这段 sn-p 代码添加到我的 functions.php 文件中!到目前为止,这让我的 cmets 出现了,人们也可以在我的博客文章中留下 cmets!但“回复”按钮尚未呈现。
<?php
function BRUM_Theme_comment( $comment, $args, $depth ){
$GLOBALS['comment'] = $comment;
?>
<?php if ( $comment->comment_approved == '1'): ?>
<li>
<article id="comment-<?php comment_ID() ?>">
<?php echo get_avatar( $comment ); ?>
<h4>
<?php comment_author_link() ?>
</h4>
<time><a href="#comment-<?php comment_ID() ?>" pubdate><?php comment_date() ?> at <?php comment_time() ?></a></time>
<?php comment_text() ?>
</article>
<?php endif;
}
到此为止!一旦我得到回复按钮,我将修改代码!
【问题讨论】:
-
嗨 Phillip,如果您找到了问题的解决方案,请随时将您的解决方案作为答案发布,然后接受它。
标签: php wordpress wordpress-theming