wordpress评论表单样式

时间:2015-03-05 14:02:43

标签: wordpress

我已将HTML模板集成到Wordpress主题中。在菜单区域有一个名为Blog的菜单。点击该菜单我想显示所有帖子。点击某些特定帖子标题后,应该转到单个帖子的页面。在该页面上应该显示一些评论,这些评论是由某人以及评论表格在前面发布的,通过评论表格可以对该帖子发表评论。

以下是我的blog.php代码

    <?php
/*
Template Name: Blog
*/
?>
<?php get_header(); ?>
        <div id="inner_contant">
            <div id="all_post">
                <?php
                    $myposts = get_posts('');
                    foreach($myposts as $post) :
                    setup_postdata($post);
                ?>
                <h2><a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
                <div class="author">Posted by <?php the_author(); ?></div>
                <div class="post_excerpt"><?php the_excerpt(); ?></div>
                <?php endforeach; wp_reset_postdata(); ?>
            </div>
        </div>
<?php get_footer(); ?>

以下是我的single.php代码

    <?php
/*
* The template for displaying all single posts and attachments
*/
?>
<?php get_header(); ?>
<div id="single_post_wrap">
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <h2><?php the_title(); ?></h2>
    <div class="time_and_author"><?php the_time('F jS, Y') ?> by <?php the_author() ?></div>
    <div class="post_content"><?php the_content(); ?></div>
    <p>Posted in <?php the_category(', ') ?> | <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
    <?php endwhile; endif; ?>
        <?php  foreach (get_comments() as $comment): ?>
        <div><?php echo $comment->comment_author; ?> said: "<?php echo $comment->comment_content; ?>".</div>
        <?php endforeach; ?>
    <?php comments_template(); ?>    
</div>
</div>
<?php get_footer(); ?>

以下是我的comments.php代码

    <?php $comment_args = array(
            'comment_notes_after' => '',
            'title_reply' => 'Have something to say?'
        ) ?>
<?php comment_form($comment_args); ?>

我想在评论表单中添加一些样式。我尝试了所有的事情,但没有为我工作。提前感谢那些能帮助我的人。

1 个答案:

答案 0 :(得分:0)

WordPress'comment_form function打印一个id为'commentform'的表单。因此,您可以使用CSS来设置此表单的样式。

form#commentform {
    // your styles.
}

form#commentform input {
    // your styles for inputs
}

/* default class of submit button is 'submit'. For changing it: add a
* key=>value to comment_form args like 
* 'class_submit' => 'your_submit_class'
*/
form#commentform .submit {
    // your submit button styles.
}

此外,您可以更改评论表单的ID,如下所示:

<?php $comment_args = array(
    'comment_notes_after' => '',
    'title_reply' => 'Have something to say?',
    'id_form' => 'myAwesomeCommentForm'
) ?>
<?php comment_form($comment_args); ?>
相关问题