How to get the result of comments_number() as a string instead of printing it out?
Easiest way: ob_start(); comments_number(); $data = ob_get_clean(); $data will contain the text.
Easiest way: ob_start(); comments_number(); $data = ob_get_clean(); $data will contain the text.
Aha, I think my syntax was wrong. I changed: action: ‘do_ajax’, data: { ‘post_id’ : ’72’ //using a post id that I *know* has comments, for testing! }, to: data: { ‘action’ : ‘do_ajax’, ‘post_id’ : ’72’ }, and I’m getting the correct response from the console.log which shows: [{“comment_ID”:”1″,”comment_post_ID”:”1″,”comment_author”:”Mr WordPress”,”comment_author_email”:””,”comment_author_url”:”http:\/\/wordpress.org\/”,”comment_author_IP”:””,”comment_date”:”2012-08-28 19:55:20″,”comment_date_gmt”:”2012-08-28 19:55:20″,”comment_content”:”Hi, this is … Read more
the link is called from within comment_form() (/wp-includes/comment-template.php line 1539) : ‘must_log_in’ => ‘<p class=”must-log-in”>’ . sprintf( __( ‘You must be <a href=”https://wordpress.stackexchange.com/questions/71100/%s”>logged in</a> to post a comment.’ ), wp_login_url( apply_filters( ‘the_permalink’, get_permalink( $post_id ) ) ) ) . ‘</p>’, and uses wp_login_url() (/wp-includes/general-template.php lines 224+) which uses a filter on its return: return apply_filters(‘login_url’, … Read more
Check for the comment_parent: if( ‘0’ != $comment->comment_parent ){ // this is a reply }
You can add the following code in function.php $subscriber= get_role(‘subscriber’); $subscriber->add_cap(‘edit_comment’); Meanwhile edit_comment is only supported in version 3.1 or newer Or you can use this plugin link
Do not delete the comment. One comment could have multiple children, and moving the replies up would create a false impression in any case. The real question here is why someone wants to delete a comment and how you could react: The content is obsolete or wrong: Add a note, mark it as outdated. The … Read more
As per the documentation: $page[‘comment_status’] = ‘closed’; // allowed values: ‘closed’ or ‘open’
Create a page template to display the comments for the particular “review” aka post. Then you can link to that page and include the post ID in the url and $_GET the post ide from the url on the new page, then query the post and display its comments. This should point you in the … Read more
The wp_notify_postauthor() function is pluggable meaning that you can copy the code and paste it into a plugin file or theme functions file keeping the same function name and WordPress will use your version rather than its own. Edit your version of the function to send as much or as little information as you like.
It looks like WP_Comment_Query() only supports a single post type. You can adjust it, by using the comments_clauses filter. Try for example: $defaults = array( ‘number’ => 5, ‘post_type’ => array( ‘post’,’authors’,’movies’ ), ); add_filter( ‘comments_clauses’, ‘wpse_121051’, 10, 2 ); $comments = get_comments($defaults) where /** * Support for multiple post types for comments * * … Read more