Community Forums › Forums › Design Tips and Tricks › Comment Policy Box
This topic contains 4 replies, has 4 voices, and was last updated by snakeair 7 months ago.
-
AuthorPosts
-
November 15, 2012 at 9:07 pm #247
Playing around with some code to implement a “comment policy box” as per the instructions found here. It works but with a minor problem: the text appears AFTER the list of comments and BEFORE the comment form, which is the expected behaviour. While this is fine if there are no comments or even just a couple of comments the problem comes into play if there are many comments. For instance, if there are say half dozen comments and someone clicks the “reply” button the comment form loads BUT the added text does not – it stays at the bottom of the page per the genesis_after_comments hook meaning it will never be seen.
After perusing the old forum and visiting this Codex page I hobbled together the following:
/** Add a comment policy box */
add_filter('genesis_comment_form_args', 'custom_comment_form_args');
function custom_comment_form_args($args) {
$args['comment_notes_before'] = '<p class="comment-policy">' . __( '<small><strong>Comment Policy:</strong> Lorem ipsum dolor sit amet, consectetur adipiscing elit.</small>' ) . ( $req ? $required_text : '' ) . '</p>';
return $args;
}This will add the given text right AFTER the Speak Your Mind heading or whatever making it a part of the comment form itself. This means of course it will be visible if someone clicks the reply button since it will load along with the comment form.
My question: is the above correctly written? While it seems to work I want to make sure it is the proper way to write it.
Blog | Twitter | GitHub | Google Code
November 16, 2012 at 8:32 pm #392Looks good to me. Technically the HTML and translatable text should be separated using sprint() but I’m assuming you aren’t even translating this, so I’d let it ride.
November 17, 2012 at 11:22 am #442HTML and translatable text should be separated using sprint()
Good catch! Thanks Nick!
Blog | Twitter | GitHub | Google Code
November 18, 2012 at 8:41 am #529I like this. Nice snippet!
November 18, 2012 at 2:07 pm #569I just installed this code. Thank you Len. (I was using the old code you originally linked to)
Newbiz Advertising Blog – An Excellent Link Building and Resource Blog
-
AuthorPosts
You must be logged in to reply to this topic.