Pre_get_comments and orderby comment_karma

I think you’re close with your 2nd snippet, but you should be using meta_value_num instead of meta_key_num. $query->set( ‘meta_key’, ‘comment_karma’ ); $query->set( ‘orderby’, ‘meta_value_num’ ); See the WP_Query orderby docs for more info.

Remove rel=”ugc” from links in comments

The rel=ugc is added by a default filter on pre_comment_content. You can disable this by adding the following line to your functions.php: remove_filter (‘pre_comment_content’, ‘wp_rel_ugc’, 20); This may not be wise. If at some point you change your mind, you would have to go through all comments to add it. It is problably better to … Read more

How to add embed image in comments?

You can do that by using the comment_text filter. It runs for each comment, so with some regex you can find all links in the comment and loop through them. You make one more check to make sure the link has an image extension (jpg, jpeg, png, etc). If it does, we can embed it … Read more

Get Comment Text via REST API

A brief introduction and what does wp.apiRequest() return wp.apiRequest() is one of the three JavaScript API written by WordPress (the other two JavaScript APIs are the Backbone JavaScript Client and wp.apiFetch()), which we can use to communicate with the WordPress REST API, and as for wp.apiRequest(), it uses jQuery.ajax() which returns a jqXHR object that … Read more