How can someone submit a comment when my site has no comment field?
You could also use the hook pre_comment_on_post to exit early: add_action( ‘pre_comment_on_post’, ‘_scalar_wp_die_handler’ ); This will not change the database.
You could also use the hook pre_comment_on_post to exit early: add_action( ‘pre_comment_on_post’, ‘_scalar_wp_die_handler’ ); This will not change the database.
The easiest thing to do is to wrap the code that displays the comments in a conditional like this: if ($page === $numpages) { echo ‘last page’; // this is the last of the <!–nextpage–> pages } That requires a theme edit, so it is only a good solution if this is a theme you’ve … Read more
wp_insert_comment() is low level function, it only saves passed data without concern for what it contains. If you are looking to replicate sanitizing WP does on comment data (totally good idea 🙂 you are probably looking for higher level wp_new_comment().
Debug ideas: You could try to see if this has any effect: add_filter( ‘bp_core_fetch_avatar_no_grav’, ‘__return_true’ ); But you should check out the parameters that go through the bp_core_fetch_avatar filter to see if they are correct (untested): add_filter( ‘bp_core_fetch_avatar’, ‘my_bp_core_fetch_avatar’, 99, 9 ); function my_bp_core_fetch_avatar( $html, $params, $item_id, $avatar_dir, $css_id, $html_width, $html_height, $avatar_folder_url, $avatar_folder_dir ) { … Read more
wp_list_comments() accepts a walker in the array of its first parameter. This is a class that renders the output. If you don’t provide one, the default class will be used, Walker_Comment. You can find it in wp-includes/comment-template.php. To change the complete comment list out, create a custom walker in your functions.php which extends the default … Read more
You should consider hooking into the comment_class() and post_class() filters, if your theme supports it. Using the comment_class filter: We can add the following filter: /** * Add a custom comment class, based on a given comment author’s user meta field. * * @see http://wordpress.stackexchange.com/a/170443/26350 */ add_filter( ‘comment_class’, function( $classes, $class, $comment_id, $post_id ) { … Read more
Yes, of course it won’t show any name for guest comments because they are not registered users of your website so they don’t have any nickname associated. What you can do in this situation, is add a check before printing the nickname, if comment was made by a user or a guest. And act accordingly. … Read more
This is possible using the comment_post action, and the GFAPI class which handles entries in WordPress. What you need to first is add using comment_form_default_fields a field which is a checkbox. function add_to_email_list_field($fields) { $fields[‘add-to-email’] = ‘<p class=”comment-form-public”> <input id=”addtoemail” name=”addtoemail” type=”checkbox” /> <label for=”addtoemail”> Check this box to add yourself to our email list. … Read more
This should do the trick, I guess: $args = array( ‘number’ => 10, ‘order’ => ‘DESC’, ‘status’ => ‘approve’, ‘parent’ => 0 ); $comments = get_comments( $args ); You can find full list of arguments in Codex.
You could instead try the following replacement: /** * Add itemprop attribute to the comment reply link */ add_filter(‘comment_reply_link’, function( $html ) { if( false === stripos( $html, ‘itemprop=”‘ ) ) $html = str_ireplace( ‘<a ‘, ‘<a itemprop=”replyToUrl” ‘, $html ); return $html; }, 99 ); through the comment_reply_link filter. The HTML generation, of the … Read more