• Hi,

    I am wanting to add a few extra fields to my comments form. I have a found a few blog posts about using the comment_form_default_fields and I have added the following code to my functions.php

    <?php 
    
    add_filter('comment_form_default_fields','my_fields');
    function my_fields($fields) {
    
        // New fields
        $fields['title'] = '<label>Title:</label><input type="text" name="title" value="'.(!empty($_POST['title']) ? $_POST['title'] : '').'" />';
        $fields['tracks'] = '<label>Tracks:</label><input type="text" name="tracks" value="'.(!empty($_POST['tracks']) ? $_POST['tracks'] : '').'" />';
        $fields['format'] = '<label>Format:</label><input type="text" name="format" value="'.(!empty($_POST['format']) ? $_POST['format'] : '').'" />';
    
        return $fields;
    }
    ?>

    Do I now need to do something else? The fields show up on the comments form on the website but when you post a comment the new fields dont get posted or come through to the back end for approval. Any help would be grealty appreciated.

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Comment form?’ is closed to new replies.