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

How can I include the user id inside of a shortcode php output?

So I’m assuming the “current commenter” is actually the current user logged into WP. So to get the current user ID, you can simply use get_current_user_id: echo do_shortcode(“[theplugin_user_data user_id='” . get_current_user_id() . “‘]”); UPDATE Ok, so we want, then, the comment’s author ID: //$comment = get_comment(); // in your case, it seems you already have … 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

duplicate comment section functionality and call it something else for custom post types

You can still use the core comment functionality for the custom post type, then filter the edit-comments.php admin screen and create a new admin page with the required comments table. Step 1. Removing the comments from the edit-comments.php admin screen can be done by using the comments_clauses filter: <?php // Remove comments for specific post … Read more

get_comments_number() returns 0

From quick look at the source there seems to be three possibilities: get_post() returned falsy value, so current post context is invalid in some way. $post->comment_count is 0. get_comments_number filter is being used to adjust the output. Most commonly it would be case 1/2 with something interfering with global post context, dump get_post() at the … Read more