2013-07-26 141 views
0

我试图调整默认的Wordpress评论表单,以便它与Foundation框架一起工作。自定义Wordpress评论表

这是我使用的内部functions.php迄今为止代码:我正在寻找一种方式来定制以同样的方式,因为一些其他输入提交按钮

function pondera_comment_form() { 
    $comment_args = array(
     'title_reply'=>'Have something to say?', 
     'fields' => apply_filters('comment_form_default_fields', 
     array(
      'author' => '<div class="small-12 large-6 columns">' . '<label for="author">' . __('First Name') . '</label> ' . ($req ? '<span>*</span>' : '') . '<input id="author" name="author" type="text" value="' . esc_attr($commenter['comment_author']) . '" size="30"' . $aria_req . ' /></div>', 
      'email' => '<div class="small-12 large-6 columns">' . '<label for="email">' . __('Email Address') . '</label> ' . ($req ? '<span>*</span>' : '') . '<input id="email" name="email" type="text" value="' . esc_attr( $commenter['comment_author_email']) . '" size="30"' . $aria_req . ' />'.'</div>', 
      'url' => '') 
     ), 
     'comment_field' => 
     '<div class="small-12 large-12 columns">' . '<label for="comment">' . __('Comments') . '</label>' . '<textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea>' . '</div>', 
     'comment_notes_before' => '', 
     'comment_notes_after' => '', 
    ); 
    comment_form($comment_args); 
} 

,但我不确定如何做到这一点。我想把它包装在这个<div class="small-12 columns>以及添加一个.button类到输入本身。

我也想为WP生成的<h3>标题做同样的事情。

+0

没有你在你的主题的comments.php文件?如果是这样,那么你可以通过添加任何你想要的按钮来直接修改表单,所以它的风格就像基础。我一直在修改评论表单。然而这将取决于你的主题是如何设置的。 – sulfureous

+0

我从头开始创建主题,所以我几乎可以使用任何方法。我有一个comments.php文件,目前这个概述显示了评论本身,然后有一个'<?php pondera_comment_form(); ?>引用来显示表单。 (这是我总是这样做的。)然后我使用这个函数来调整功能。我没有意识到你可以从头开始编写代码,是否有资源页面显示如何正确执行此操作? – Sheixt

+1

我会建议您检查白板框架。 http://whiteboardframework.com/写这个主题的人有一个非常好的comments.php模板,它显示了我建议的方法,或许这是一个很好的例子,让我们知道它是否让你更接近你想要的位置与此同在。祝你好运。 – sulfureous

回答

1

好吧,我已经意识到这是在comments.php之内是多么的容易。非常感谢@sulfureous指出我正确的方向。

对于任何人谁是有兴趣的,这里是我放在comments.php内(最初引用的函数随后删除)代码:

<div class="row"> 
    <div class="large-12 columns"> 
     <?php if(comments_open()) : ?> 
      <h3>Have something to say?</h3> 
      <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="comments-form"> 
       <div class="row"> 
        <div class="small-12 large-6 columns"> 
         <label for="author"><?php _e('Name'); ?> <?php if($req) echo "(required)"; ?></label> 
         <input type="text" name="author" id="author" value="<?php echo $comment_author; ?>" size="22" tabindex="1" /> 
        </div> 
        <div class="small-12 large-6 columns"> 
         <label for="email"><?php _e('Email'); ?> <?php if($req) echo "(required)"; ?></label> 
         <input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="22" tabindex="2" /> 
        </div> 
       </div> 
       <div class="row"> 
        <div class="small-12 columns"> 
         <label for="comment"><?php _e('Comment'); ?></label> 
         <textarea name="comment" id="comment" cols="100%" rows="10" tabindex="3"></textarea> 
        </div> 
       </div> 
       <div class="row"> 
        <div class="small-12 columns"> 
         <input name="submit" type="submit" id="submit" tabindex="4" class="btn" value="Post Comment" /> 
         <input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" /> 
        </div> 
       </div> 
       <?php do_action('comment_form', $post->ID); ?> 
      </form> 
     <?php else : ?> 
      <h5><?php _e('Sorry, the comments are now closed.'); ?></h5> 
     <?php endif; ?> 
    </div> 
</div>