Comment Policy Box

Community Forums Forums Design Tips and Tricks Comment Policy Box

This topic is: not resolved

This topic contains 4 replies, has 4 voices, and was last updated by  snakeair 2 years, 1 month ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #247

    Len
    Participant
    Post count: 54

    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:

    [php]/** 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;
    }[/php]

    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.


    • This topic was modified 2 years, 1 month ago by  Len.
    • This topic was modified 2 years, 1 month ago by  Len.
    • This topic was modified 2 years, 1 month ago by  Len.
    • This topic was modified 2 years, 1 month ago by  Len.
    • This topic was modified 2 years, 1 month ago by  Len.
    • This topic was modified 2 years, 1 month ago by  Len.
    • This topic was modified 2 years, 1 month ago by  Len.
    • This topic was modified 2 years, 1 month ago by  Len.
    • This topic was modified 2 years, 1 month ago by  Len.
    • This topic was modified 2 years, 1 month ago by  Len.
    #392

    nickthegeek
    Keymaster
    Post count: 756

    Looks 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.

     

     

    #442

    Len
    Participant
    Post count: 54

    HTML and translatable text should be separated using sprint()

    Good catch! Thanks Nick!


    #529

    Jon Weiss
    Moderator
    Post count: 14
    #569

    snakeair
    Participant
    Post count: 164

    I just installed this code. Thank you Len.  (I was using the old code you originally linked to)

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.