How to change title attribute returned by comments_popup_link()?

If you look into the function comments_popup_link() you will see the following code at the end: $title = the_title_attribute( array(‘echo’ => 0 ) ); echo apply_filters( ‘comments_popup_link_attributes’, ” ); echo ‘ title=”‘ . esc_attr( sprintf( __(‘Comment on %s’), $title ) ) . ‘”>’; comments_number( $zero, $one, $more ); echo ‘</a>’; // last line Note the … Read more

Wpdb query for comment meta for current post

You can join to the comments table and use get_the_ID(): // set the meta_key to the appropriate custom field meta key $meta_key = ‘rating_total’; $ratingtotals = $wpdb->get_var( $wpdb->prepare( ” SELECT sum(cm.meta_value) FROM $wpdb->commentmeta AS cm JOIN $wpdb->comments AS c ON (c.comment_ID = cm.comment_id) WHERE cm.meta_key = %s AND c.comment_post_ID = %d “, $meta_key, get_the_ID() ) … Read more

How would I count the number of times a comment meta field’s value is in a post’s entire comments?

You should be able to do a meta_query in a WP_Comment_Query(): $args = array( ‘post_id’ => ‘post-id-here’, ‘meta_query’ => array( array( ‘key’ => ‘fish’, ‘value’ => ‘shark’, ‘compare’ => ‘LIKE’ ) ) ); // Query the comments $comment_query = new WP_Comment_Query( $args ); // Count the number of comments $count = count ( $comment_query ); … Read more

How to get the average of the values from the comment meta

If you need to show the averages in the content, you need to pre-calculate them (before showing the comments). My approach would be having a custom meta in the post with the calculated averages and modify those metas every time a new comment (rating) is saved. Something like add_action(“comment_post”, “wpse16733_updateAVGs”); function wpse16733_updateAVGs($comment_ID, $approved){ if ($approved){ … Read more

Display comment meta data after quick update

I think the action wp_ajax_get-comments is not triggered, if you quick-update the comment. You should check, which ajax request is triggered on the update and then change your code into: if( doing_action( ‘wp_ajax_get-comments’ ) || doing_action( ‘wp_ajax_quick-update-action’ ) ){ … } I am not able to test this code at the moment, but i hope … Read more

How to put this result inside that result?

Run the loop in advance and populate an array, which in turn you include in the $result afterward. <?php // Create an empty array $comlistall = array(); foreach ( $comments as $comment ){ $comlistall[] = $comment; // <= Populate the array with the comments in the loop }; $rtitlez = get_the_title(); $rimgz = get_the_post_thumbnail_url(get_the_ID(), ‘full’); … Read more

Add a drop down list to comment form?

Filter comment_form_field_comment to add a select element with a label. Add a callback to the action comment_post to save the value. Filter comment_text to show the value for a comment. Sample code: add_filter( ‘comment_form_field_comment’, function( $field ) { global $wp_roles; $user = wp_get_current_user(); $select=”<p><label for=”roleselect”>Your role:</label> <select name=”prefix_role” id=”roleselect”> <option value=””>Select a role</option>”; foreach ( … Read more

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