0

I modified the fields in comment_form() to hide the website field and created one that's for a phone number. So far so good.

The problem is that this Phone field shows last, below the cookie consent. I'd like cookie consent to be last so I found this code in an answer in a similar question and I just changed the name of the field for my case. Basically he claims that just be unsetting and setting it again it will end up at the end of the array and will show last.

add_filter( 'comment_form_fields', 'move_comment_field' );
function move_comment_field( $fields ) {
    $comment_field = $fields['cookies'];
    unset( $fields['cookies'] );
    $fields['cookies'] = $comment_field;
    return $fields;
}

It doesn't work for me I'm afraid. Has something changed in WP since this question was asked that could explain the error? I'm new to this and because of reputation I couldn't comment on that question.

It seemed like a very simple solution (way simpler than the others) so I'd like to know if either this answer was wrong, something has changed in WP that makes it obsolete or I'm doing something wrong.

Thank you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.