通常我不会在我的网站上使用评论,但是我使用评论功能作为一种实时提要推荐页面。为了做到这一点,我借用了comments.php
以及functions.php
来自TwentyEleven主题。我目前正在努力解决的是评论/表单在上的显示方式the site理想情况下,我希望表格在左边(内侧.content-left
) 注释列表位于右侧(内部.content-right
). 目前,评论列表位于.content-left
我希望它在哪里.content-right
. 如何将其从左侧移除?
共有php
<?php
/*
Template Name: Share
*/
?>
<?php get_header(); ?>
<h1>We\'re All Ears.</h1>
<div class="content-left">
<?php comments_template(); ?>
</div><!-- end content-left -->
<div class="content-right">
<?php wp_list_comments( array( \'callback\' => \'twentyeleven_comment\' )); ?></ul>
</div><!-- end content-right -->
<?php get_footer(); ?>
评论。php
<?php
/**
* The template for displaying Comments.
*
* The area of the page that contains both current comments
* and the comment form. The actual display of comments is
* handled by a callback to twentyeleven_comment() which is
* located in the functions.php file.
*
* @package WordPress
* @subpackage Twenty_Eleven
* @since Twenty Eleven 1.0
*/
?>
<div id="comments">
<?php if ( post_password_required() ) : ?>
<p class="nopassword"><?php _e( \'This post is password protected. Enter the password to view any comments.\', \'twentyeleven\' ); ?></p>
</div><!-- #comments -->
<?php
/* Stop the rest of comments.php from being processed,
* but don\'t kill the script entirely -- we still have
* to fully load the template.
*/
return;
endif;
?>
<?php // You can start editing here -- including this comment! ?>
<?php if ( have_comments() ) : ?>
<?php if ( get_comment_pages_count() > 1 && get_option( \'page_comments\' ) ) : // are there comments to navigate through ?>
<nav id="comment-nav-above">
<h1 class="assistive-text"><?php _e( \'Comment navigation\', \'twentyeleven\' ); ?></h1>
<div class="nav-previous"><?php previous_comments_link( __( \'← Older Comments\', \'twentyeleven\' ) ); ?></div>
<div class="nav-next"><?php next_comments_link( __( \'Newer Comments →\', \'twentyeleven\' ) ); ?></div>
</nav>
<?php endif; // check for comment navigation ?>
<ol class="commentlist">
<?php
/* Loop through and list the comments. Tell wp_list_comments()
* to use twentyeleven_comment() to format the comments.
* If you want to overload this in a child theme then you can
* define twentyeleven_comment() and that will be used instead.
* See twentyeleven_comment() in twentyeleven/functions.php for more.
*/
wp_list_comments( array( \'callback\' => \'twentyeleven_comment\' ) );
?>
</ol>
<?php if ( get_comment_pages_count() > 1 && get_option( \'page_comments\' ) ) : // are there comments to navigate through ?>
<nav id="comment-nav-below">
<h1 class="assistive-text"><?php _e( \'Comment navigation\', \'twentyeleven\' ); ?></h1>
<div class="nav-previous"><?php previous_comments_link( __( \'← Older Comments\', \'twentyeleven\' ) ); ?></div>
<div class="nav-next"><?php next_comments_link( __( \'Newer Comments →\', \'twentyeleven\' ) ); ?></div>
</nav>
<?php endif; // check for comment navigation ?>
<?php
/* If there are no comments and comments are closed, let\'s leave a little note, shall we?
* But we don\'t want the note on pages or post types that do not support comments.
*/
elseif ( ! comments_open() && ! is_page() && post_type_supports( get_post_type(), \'comments\' ) ) :
?>
<p class="nocomments"><?php _e( \'Comments are closed.\', \'twentyeleven\' ); ?></p>
<?php endif; ?>
<?php comment_form(); ?>
</div><!-- #comments -->
功能。php
<?php
if ( ! function_exists( \'twentyeleven_comment\' ) ) :
/**
* Template for comments and pingbacks.
*
* To override this walker in a child theme without modifying the comments template
* simply create your own twentyeleven_comment(), and that function will be used instead.
*
* Used as a callback by wp_list_comments() for displaying the comments.
*
* @since Twenty Eleven 1.0
*/
function twentyeleven_comment( $comment, $args, $depth ) {
$GLOBALS[\'comment\'] = $comment;
switch ( $comment->comment_type ) :
case \'pingback\' :
case \'trackback\' :
?>
<li class="post pingback">
<p><?php _e( \'Pingback:\', \'twentyeleven\' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( \'Edit\', \'twentyeleven\' ), \'<span class="edit-link">\', \'</span>\' ); ?></p>
<?php
break;
default :
?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
<article id="comment-<?php comment_ID(); ?>" class="comment">
<footer class="comment-meta">
<div class="comment-author vcard">
<?php
$avatar_size = 68;
if ( \'0\' != $comment->comment_parent )
$avatar_size = 39;
echo get_avatar( $comment, $avatar_size );
/* translators: 1: comment author, 2: date and time */
printf( __( \'%1$s on %2$s <span class="says">said:</span>\', \'twentyeleven\' ),
sprintf( \'<span class="fn">%s</span>\', get_comment_author_link() ),
sprintf( \'<a href="%1$s"><time pubdate datetime="%2$s">%3$s</time></a>\',
esc_url( get_comment_link( $comment->comment_ID ) ),
get_comment_time( \'c\' ),
/* translators: 1: date, 2: time */
sprintf( __( \'%1$s at %2$s\', \'twentyeleven\' ), get_comment_date(), get_comment_time() )
)
);
?>
<?php edit_comment_link( __( \'Edit\', \'twentyeleven\' ), \'<span class="edit-link">\', \'</span>\' ); ?>
</div><!-- .comment-author .vcard -->
<?php if ( $comment->comment_approved == \'0\' ) : ?>
<em class="comment-awaiting-moderation"><?php _e( \'Your comment is awaiting moderation.\', \'twentyeleven\' ); ?></em>
<br />
<?php endif; ?>
</footer>
<div class="comment-content"><?php comment_text(); ?></div>
<div class="reply">
<?php comment_reply_link( array_merge( $args, array( \'reply_text\' => __( \'Reply <span>↓</span>\', \'twentyeleven\' ), \'depth\' => $depth, \'max_depth\' => $args[\'max_depth\'] ) ) ); ?>
</div><!-- .reply -->
</article><!-- #comment-## -->
<?php
break;
endswitch;
}
endif; // ends check for twentyeleven_comment()
?>
此外,如何让注释列表显示用户名以及其他字段的信息?