How do I add <div> tags to entire comments, not just their text

Thanks to some wonderful help here at stack exchange, I have built a comment section with a dropdown menu that adds comment_meta to the comments. I currently have a working filter that uses GET to trigger an if statement to query based on this comment_meta info. The thing I don't like is that it refreshes the page each time you click a button. I'm looking for a way to filter without having the page refresh. I think I need Javascript …
Category: Web

How to filter comments by comment_meta

EDIT: Yay, solved it! I needed to use new WP_Comment_Query( $args ) and set my $args to only include the current post and the meta chosen. Thanks! Thanks to the wonderful help of the community here, I have created a dropdown menu above my comments section to choose between BUY | SELL | TRADE | TALK. EDIT: I've changed my comment.php file. It now filters by comment_meta - YAY! Except, it gets ALL comments with this meta value. How do …
Category: Web

add_comment_meta not working properly

I have a scenario where I need to retrieve a custom field ('current_module') from a comment author's user profile and add it to a custom field ('author_current_module') associated with any comment they submit. When I include the following code in my theme's functions.php, nothing is saved to the comment's custom field (I've verified by writing out the variables up until $comment_author_module_id to my log, and everything is working properly). NOTE: I've set up the custom fields (for both users and …
Category: Web

How to check if `comment_meta` exists before inserting the comment?

I am inserting comments via wp_insert_comment and while doing so I am adding email replies only. Now, I want to check if the comment is already present or not before inserting and if does exist do not perform wp_insert_comment. Here, is my code: // Here, we insert the replies as comment to their parent email. if ((!empty($mail['header']-&gt;references )) &amp;&amp; (preg_replace('~[&lt;]~','',strstr($mail['header']-&gt;references, '@',true))) == (preg_replace('~[&lt;]~','',strstr($mail['header']-&gt;references, '@',true)))) { //echo htmlentities($mail['header']-&gt;message_id); $posts = get_posts( array( 'post_type' =&gt; 'post-type', 'meta_key' =&gt; 'ticket_id', 'meta_value' =&gt; preg_replace('~[&lt;]~','',strstr($mail['header']-&gt;references, …
Category: Web

Name of comment field differs on different sites

I have a question regarding the „name“ of the comment field of wordpress blogs. I have 2 sites, that are just available locally on my LAN. On the first site, if I inspect the comment field in firefox, I see: &lt;textarea id=&quot;comment&quot; name=&quot;comment&quot; cols=&quot;45&quot; rows=&quot;8&quot; maxlength=&quot;65525&quot; required=&quot;required&quot;&gt;&lt;/textarea&gt; On the second site I see: &lt;textarea autocomplete=&quot;new-password&quot; id=&quot;comment&quot; name=&quot;i817ab2c85&quot; cols=&quot;45&quot; rows=&quot;8&quot; maxlength=&quot;65525&quot; required=&quot;required&quot; spellcheck=&quot;false&quot;&gt;&lt;/textarea&gt; Can anybody tell me, why the name of the comment field differs on the second site? Both sites …
Category: Web

Add custom field on admin dashboard comments / reviews

I hope someone can shine me some light with regards to the problem I'm solving. Currently we can add comments / reviews on woocommerce products - via dashboard using this form: I can add a default rating value for the comment meta with this: function add_custom_comment_field( $comment_id ) { add_comment_meta( $comment_id, 'rating', 5 ); } add_action( 'comment_post', 'add_custom_comment_field' ); However I would only like to run that action when a comment is posted via dashboard for a woocommerce product. And …
Category: Web

What is the best way to grouping comments in wordpress?

In WordPress, I want to group comments by a numeric value to use each of the groups in a special parts that I want. Any of my groups have a numeric value as identifier. For example, I want to put comments 1,2,3,4,5 in group 1 and comments 6,7,8,9,10 in group 2. So the group number of comment 7 is 2 and comment 4 is 1 and etc. I use comment_karma field that exists in WordPress comments table to save the …
Category: Web

How to add a category to comments?

I am currently trying to add a category to the comments on my wordpress site. I already added a title to these and tried several ways to add a dropdown (selection) list to the comment form but I am not good in php and I always receive an error msg... Here is what I am using in functions.php to add the title field: add_action( 'comment_form_logged_in_after', 'additional_fields' ); add_action( 'comment_form_after_fields', 'additional_fields' ); function additional_fields () { echo '&lt;p class="comment-form-title"&gt;'. '&lt;label for="title"&gt;' …
Category: Web

Make every comment go to the spam folder

Wordpress comments exists in 4 states: 0 not approved 1 approved Trashed Spam When a user makes a comment it will end up in the 0 not approved folder, or if it's a spam comment directly to the spam folder. Is it possible to send every single comment to the spam folder?
Category: Web

How is the author's name given a different color?

Author's and visitors' names use the same color in comments.The point here is that the color of the author's name is different in the comments. For example, in visitor comments, name is red. But, the name of the site author should be gray. (Only in comments) I know an ID needs to be added for the author's comments. However, I could not add this ID. Therefore, the style I gave in style.css does not work either. I just tried this …
Category: Web

How to put this result inside that result?

I want my comment results to put inside anoher result. I want this result $args = array( 'post_id' =&gt;$post-&gt;ID, 'status' =&gt; 'approve', 'type' =&gt; 'review_comment', ); $comments = get_comments( $args ); $abb = $comment-&gt;comment_content; $acc = get_comment_meta($comment-&gt;comment_ID, COMMENT_TITLE_METAKEY, true); $add = get_comment_meta($comment-&gt;comment_ID, COMMENT_RATING_METAKEY, true); $aee = get_comment_date( 'd\/m\/Y' ); $aff = get_the_title(); $agg = $comment-&gt;comment_author; $comlist = "review" =&gt; [ "@type" =&gt; "Review", "headline" =&gt; $acc, "reviewbody" =&gt; $abb, "datePublished" =&gt; $aee, "itemReviewed" =&gt; [ "@type" =&gt; "Organization", "name" =&gt; …
Category: Web

Top rated posts Average rating issue

I am trying to show top rated posts, cpt with AVG rating value.I created the custom widget for this. Defaults wp posts data and AVG value is showing correct but a CPT like Movie post not showing correct AVG value. I'm using following code to achieve this. Need help public function widget( $args, $instance ) { $title = apply_filters( 'widget_title', $instance['title'] ); $posttype = $instance['posttype']; $postsperpage = $instance['postsperpage']; $postorder = $instance['postorder']; $avgrt_pos = $instance['avgrt_pos']; $image = $instance[ 'showimage' ] ? …
Category: Web

Add a drop down list to comment form?

Can somebody help me to create a drop-down menu or (radio buttons) in Wordpress comment form, so that a new user could make a selection of their user roles (for example teachers + students) ? Output from dropdown list or radio button would appear somewhere in the comments area. The best of all would also be if WordPress which already automatically populate email, login name would also display new extra field info (dropdown list OR radio button) to logged in …
Category: Web

How to get top rated posts using wp query?

I want to get top rated posts using wp query. The rating value is store in comment meta database table when some one post a comment on wp post or cpt.Please screenshot EDIT Here is my code add_action( 'comment_form_top', 'wpcr_change_comment_form_defaults'); function wpcr_change_comment_form_defaults( ) { $star1_title = __('Very bad', 'post-rating'); $star2_title = __('Bad', 'post-rating'); $star3_title = __('Meh', 'post-rating'); $star4_title = __('Pretty good', 'post-rating'); $star5_title = __('Rocks!', 'post-rating'); echo '&lt;fieldset class="rating"&gt; &lt;legend&gt;Rating&lt;span class="required"&gt;*&lt;/span&gt;&lt;/legend&gt; &lt;input type="radio" id="star5" name="rating" value="5" /&gt;&lt;label for="star5" title="'.$star5_title.'"&gt;5 stars&lt;/label&gt; …
Category: Web

Upload images with comment

EDIT: I finally got the right answer; see my own answer beneath this post for everyone that's interested. After searching for a couple of days and trying over and over again I really got stuck. I've a client who collects customer experiences on his website by using the comment form; all comments are displayed as a customer review. So far so good. But since it's company does a lot with traveling, he needs to give his customers to upload up …
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.