wp_new_comment requires author url and author email

The example from the codex, the array of argument is now required. global $post, $current_user; //for this example only 🙂 $commentdata = array(‘comment_post_ID’ => $post->ID, // to which post the comment will show up ‘comment_author’ => ‘Another Someone’, //fixed value – can be dynamic ‘comment_author_email’ => ‘[email protected]’, //fixed value – can be dynamic ‘comment_author_url’ => … Read more

How to display category name from commenter’s custom post

You can use get_the_category This can be done by either using setup_postdata( $comment_author_post ) or by passing the post ID using $comment_author_post->ID USING setup_postdata() $args = array( ‘post_type’ => array( ‘post’ ), ‘post_status’ => array( ‘publish’ ), ‘author’ => $comment->user_id, ‘orderby’ => ‘post_date’, ‘order’ => ‘ASC’, ‘posts_per_page’ => 1 ); $comment_author_posts = get_posts( $args ); … Read more

Additional content every x comments

Here’s one approach using the following custom input arguments: wp_list_comments( [ ‘_inject_period’ => 5, ‘_inject_content’ => [ ‘AAA’, ‘BBB’, ‘CCC’ ], ] ); where we setup the inject period and define the content to inject. This could be supported by the following demo plugin that extends the \Walker_Comment class and enhances the start_el() method: <?php … Read more

why can’t I retrieve the comment ID?

So @Jack Johansson and @Dave Romsey helped me to make it work.So I will put the solution here: function ji_update_comment_date($comment,$commentarr){ $comment = get_comment( $comment ); $commentarr = array( ‘comment_ID’=>$comment->comment_ID, ‘comment_date’=>date(“Y-m-d H:i:s”), ‘comment_date_gmt’=> date(“Y-m-d H:i:s”) ); wp_update_comment( $commentarr );} add_action(‘comment_unapproved_to_approved’,’ji_update_comment_date’); I don’t understand why comment_ID() and get_comment_ID() won’t work in this scenario. But get_comment is surely … Read more

How to permanently delete pages I have already trashed?

On the ‘Page’ admin page, you can search for content inside a page, which might be helpful if you have lots of pages. But, if you first log in as admin, then go to the URLs that aren’t supposed to be there (but are, assuming they don’t “404”), then you can use the ‘Edit’ button … Read more

comment_notes_before not working

As noted by @birgire, the comment_notes_before argument is only shown to users who are not logged in. If you look at the source, there is an if construct that checks if a user is logged in. If they are logged in, then a filter and an action fired. If not, then the comment_notes_before text is … Read more

Update comment meta for all comments of specific post

Your approach will be very slow if there are N no of comments. Use following approach for much faster execution. global $wpdb; $sql=” SELECT GROUP_CONCAT( comment_ID ) AS ids FROM `wp_comments` WHERE comment_post_ID = “.$POST_ID; $ids = $wpdb->get_results($sql, ARRAY_A); if(isset($ids[0][‘ids’]) && $ids[0][‘ids’] != ”){ $wpdb->query(‘ UPDATE wp_commentmeta SET meta_value = 0 WHERE comment_id IN (‘.$ids[0][‘ids’].’) … Read more

I update a post and it creates a pingback? Any idea why?

I quote a sentence from WpBeginners about what a pingback is: Pingback allows you to notify other bloggers that you have linked to their article on your website. So it means you probably have a link to someone else’s blog, which results in a pingback each time you update or publish a post in the … Read more

Why there is still an approved comment after deleting all?

@Nikolay Yes well, I checked the database, there were no post, pages or products at the time, but then someone left a comment while I was testing with the “under construction” disabled, once I answered this comment everything turned out alright, the invisible comment was gone and now there are only the two comments, one … Read more