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

First off, you need to fix the comment_meta value. It should be an array of meta key and value pairs, and not just the meta value. So give the meta a key (or name), e.g. message_id, and then do something like so: ‘comment_meta’ => array( ‘message_id’ => preg_replace(‘~[<]~’,”,strstr($mail[‘header’]->message_id, ‘@’,true)), ), Now to check if a … Read more

How to filter comments by comment_meta

I needed to use new WP_Comment_Query and set my $args to show only this post, with the meta attached. Hope this helps someone! <?php comment_form(); if (have_comments()) : ?> <div class=”container”> <div class=”btn-group flex”> <button type=”button” onclick=”window.location.href=”https://wordpress.stackexchange.com/questions/406158/<?php echo the_permalink();?>/?cmeta=ALL””>SHOW ALL</button> <button type=”button” onclick=”window.location.href=”<?php echo the_permalink();?>/?cmeta=BUY””>BUY</button> <button type=”button” onclick=”window.location.href=”<?php echo the_permalink();?>/?cmeta=SELL””>SELL</button> <button type=”button” onclick=”window.location.href=”<?php echo the_permalink();?>/?cmeta=TRADE””>TRADE</button> … Read more

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

Currently your comment markup looks similar to the following: <li class=”comment byuser comment-author-rcotwunite odd alt thread-odd thread-alt depth-1″ id=”comment-7902″> <div id=”div-comment-7902″ class=”comment-body”> <div class=”comment-author vcard”><!– … –></div> <div class=”comment-meta commentmetadata”><!– … –></div> <div class=”filterDiv SELL show”> <div class=”container”> <p class=”wantosec”>I want to SELL</p> <p>SUP YALL im here to sell some stuff</p> <div class=”reply”><!– … –></div> … Read more

Editing custom fields for comments

I think you’ve way over-complicated things. Assuming private is a checkbox, just check for it being set, and act accordingly. With form $_POST data, a checkbox will send its value if checked, and will send nothing if not checked: if ( isset( $_POST[‘private’] ) ) { update_comment_meta( $comment_id, ‘private’, ‘private’ ); } else { delete_comment_meta( … 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

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