Comments on future posts

You can not enable comments in future posts. Those posts are not public and are not private, so they verify the conditional in line 61 of wp-comments-post.php file; that conditional is (WP 4.1.1): } elseif ( ! $status_obj->public && ! $status_obj->private ) { /** * Fires when a comment is attempted on a post in … Read more

How to add a category to comments?

OK, I finally made it following this crystal clear tut Consequently, my functions.php became: add_action( ‘comment_form_logged_in_after’, ‘additional_fields’ ); add_action( ‘comment_form_after_fields’, ‘additional_fields’ ); function additional_fields () { echo ‘<p class=”comment-form-title”>’. ‘<label for=”title”>’ . __( ‘Titre (Je peux…)’ ) . ‘</label>’. ‘<input id=”title” name=”title” type=”text” size=”30″ tabindex=”5″ /></p>’; echo ‘<strong><label for=”category”>Cette solution est particulièrement utile…</label></strong> <select id=”category” … Read more

Custom comment field not showing when logged-in

I’m not sure I fully understand your question, but to add some HTML (just over or under the submit field) that is visible to both logged-in and logged-out users, you can try the following: add_filter( ‘comment_form_submit_field’, function( $submit_field ) { //———————————– // Adjust the prepend to your needs //———————————– $prepend = ‘<p> Prepend some HTML … Read more

How to properly enable comments form in page template

I think it could be a problem with get_comments_number which returns numeric, though theoretically it should test this way too… you could try instead: if ( comments_open() || have_comments() ) : comments_template(); endif; OR if ( comments_open() || (get_comments_number() > 0) ) : comments_template(); endif;

Custom comment-field form arrangement [closed]

Sure, you could use the comment_form_field_comment filter to inject content (extra fields or whatever) above the comment field: function comment_form_field_comment_add_field( $field ) { $new_field = ‘<p class=”comment-form-extra”><label for=”extra”>Extra Field</label> <input id=”extra” name=”extra” type=”text” value=”” size=”30″ aria-required=”true” required=”required”></p>’; $field = $new_field . $field; return $field; } add_filter( ‘comment_form_field_comment’, ‘comment_form_field_comment_add_field’ ); You could also switch that around … Read more

Get comment id of the individual comments in comment list when modifying comment posted using comment text filter

The comment_text filter passes the comment as one of its params: echo apply_filters( ‘comment_text’, $comment_text, $comment, $args ); So you don’t need to call get_comment_ID(), you can just access the ID from the $comment object. Change: add_filter( ‘comment_text’, ‘modify_comment’); to: add_filter( ‘comment_text’, ‘modify_comment’, 0, 3 ); And then: function modify_comment( $comment_text, $comment, $args ){ wp_enqueue_script( … Read more

how to add a comment button to be displayed only for the posts in the home page [closed]

In the template part used in the loop on your home page, something like this should get you started. Someplace after the_content(); or the_excerpt(), depending on what you’re using. <?php if ( is_home() ) { ?> <a class=”button” href=”<?php echo esc_url( get_permalink() );?>#comments”> Comment Link Text </a> } ?> You can make it look like … Read more

Send email messages after comment was submitted

For comment approved, you can review this question Approve comment hook? For comment submitted, you can hook into the comment_post hook, like function show_message_function( $comment_ID, $comment_approved ) { if( 0 === $comment_approved ){ //function logic goes here } } add_action( ‘comment_post’, ‘show_message_function’, 10, 2 ); Code copied from https://developer.wordpress.org/reference/hooks/comment_post/

How to create post comment from different domain

This quite rare setup so it is hard to recommend one way or another. Having worked with comments before I would recommend to stick with WordPress API functions (wp_insert_comment() and so on) for manipulating them. While DB structure is indeed simple you don’t account for all the hooks firing and other things that might be … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)