WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to remove the comment_form's 'title_reply' field? (2 posts)

  1. hellodrifter
    Member
    Posted 3 years ago #

    I don't need the title_reply field as I've already styled a h4 title outside of the form.

    I've tried to remove the field inside my args array, but to no avail. Here's the code.

    <?php $comment_args = array( 'fields' => apply_filters( 'comment_form_default_fields', array(
    	'title_reply' => '',
            'email' => more code...,
            'author'=> more code...,
            'url'    => '' ) ),
    
             more code...
    );
    ?>
    <?php comment_form($comment_args); ?>

    The code for email, author and url all work fine, but when I added title_reply to the array, nothing happened. Is there something obvious I am doing wrong here?

  2. hellodrifter
    Member
    Posted 3 years ago #

    Hey, I figured out what I was doing wrong. Two things.

    First, the title_reply field needs parentheses around the single quote marks.

    'title_reply' => ( '' ),
    instead of
    'title_reply' => '',

    Second, I placed title_reply in the wrong array. My code has two arrays, one nested within the other. The inner array with the comment_form_default_fields hook seems to be specific to the email, author and url fields. Whereas my first array, with no hook, seems to effect the rest of the comment_form defaults without a hiccup.

    Here's the working code.

    <?php $comment_args = array( 'fields' => apply_filters( 'comment_form_default_fields', array(
    
    	'email'  =>  more code...,
    	'author' => more code...,
            'url'    => '' ) ), <!-- close apply_filters and second array -->
    
        'comment_field' => more code...,
        'comment_notes_after' => '',
        'title_reply' => ( '' ),
    
    );
    ?>
    <?php comment_form($comment_args); ?>

    Please correct me if my explanation is wrong. Here's a few tutorials and resources I found helpful.

    http://ottopress.com/2010/wordpress-3-0-theme-tip-the-comment-form/
    http://www.php.net/manual/en/language.types.array.php

    http://devpress.com/blog/using-the-wordpress-comment-form/

Topic Closed

This topic has been closed to new replies.

About this Topic