Tag Info

Hot answers tagged

10

It looks like you are overwriting the comment text with your commentimage_comment_text2 filter, try this to append the ratings text: add_filter( 'comment_text', 'commentimage_comment_text2' ); function commentimage_comment_text2( $comment ){ $rtt = "<br>Rating"; return $comment.$rtt; } ps: you forgot the $comment input parameter. Here is a ...


5

Assuming you'd like the facility to update this data from the quickedit box whilst viewing the list of comments, you'll need a series of actions and filters. I've tried to make appropriate comments in the necessary places for you, though bear in mind i threw this all together for you with a small amount of testing(it does work though). This should get give ...


5

Filter comment_form_field_comment to add a select element with a label. Add a callback to the action comment_post to save the value. Filter comment_text to show the value for a comment. Sample code: add_filter( 'comment_form_field_comment', function( $field ) { global $wp_roles; $user = wp_get_current_user(); $select = ...


5

To answer your first question: »How does WooCommerce add the comment_type of order_note to the dropdown in Comment Administration?«. From woocommerce-admin-init.php: function woocommerce_admin_comment_types_dropdown( $types ) { $types['order_note'] = __( 'Order notes', 'woocommerce' ); return $types; } add_filter( 'admin_comment_types_dropdown', ...


5

I would enable comments for that page and save them with a comment meta holding your object's ID. To be more specific, this is how would I tackle this issue: Hook into comment_post action and save a comment meta called my_object_id with your custom object ID as a value when posting a comment from the relevant page. To display only relevant comments, I'd ...


4

Preface Once post preview is frontend, the comment form depends on how theme handle it. I will assume in this answer that the comment form is shown using the standard comment_form() function. The previous assumption isn't enough, in fact comment_form is probably the function in WordPress core with more hooks. There is almost an hook for every line. So what ...


4

Actually you can include the editor-style.css (or any other stylesheet), just pass a "content_css" value to tinymce that points to a css file: wp_editor( $content, 'editablecontent', array( 'tinymce' => array( 'content_css' => get_stylesheet_directory_uri() . '/editor-styles.css' ) ); So the original ...


4

This is a false alarm. Many “Security Programs” do that. That’s called FUD. WordPress does not check the Referer header, because it is often empty, and real spammers send the site URL as Referer anyway. But all comment field are sanitized, so no harmful code will be injected. Install an anti-spam plugin, and everything is fine. This report is obviously ...


3

Disclaimer: I wrote parts of the Akismet WordPress plugin, though not the parts in question here. Is Akismet failing to connect to the Akismet service, notifying me, and retrying later? Yes, this is exactly what happens. If Akismet doesn't get a valid response from the servers, it reschedules the check for 20 minutes in the future. In the meantime the ...


3

To print just the total number of comments for a given post ID, use the count argument: echo get_comments( array ( // post ID 'post_id' => 149, // return just the total number 'count' => TRUE ) ); To get the total number of all comments of all posts on the current page, you can use the comment_count property ...


3

There is no argument to restrict a comment query directly to a given date. You have to filter the query later: /** * Get the number of comments for a post today. * * @param int $post_id * @return int */ function t5_count_comments_today( $post_id = NULL ) { if ( NULL === $post_id ) $post_id = get_the_ID(); add_filter( ...


3

http://codex.wordpress.org/Function_Reference/get_comments#Parameters your problem is using author_email, you need user_id i just use similar script. <?php $args = array( 'user_id' => $user->ID, 'number' => 10, // how many comments to retrieve 'status' => 'approve' ); $comments = get_comments( $args ...


3

Give it a try works perfect for me what it is doing query get the all the posts with a left jon with comments table so when a post has comment then it also has the comment_date if no comments posted on the post then in result set it will be null so i have merged the comment_date with post_date so which post has the greater date (for comment_date or ...


3

Try this: <?php $popular = new WP_Query('orderby=comment_count&posts_per_page=5'); ?> <?php while ($popular->have_posts()) : $popular->the_post(); ?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> has <?php comments_number( 'no responses', 'one response', '% responses' ); ...


3

There is no wp_comment_count in a WP_Query object, either in the "top" level as in your code-- $popular->wp_comment_count-- or in the individual post objects which is what you actually want to be checking. There is a comment_count in the post objects though, and that is what you want-- $post->comment_count. Your code should look like this (cleaned ...


3

The easiest thing to do is to wrap the code that displays the comments in a conditional like this: if ($page === $numpages) { echo 'last page'; // this is the last of the <!--nextpage--> pages } That requires a theme edit, so it is only a good solution if this is a theme you've constructed and maintain. The variables (global) $page and $numpages ...


3

When we post an empty anonymous reply, we get the following errors: The part of BBPress that's responsible for handling this, is the bbp_new_reply_handler() function, in the file /bbpress/includes/replies/functions.php. It contains these lines that are of interest to us: // User is anonymous if ( bbp_is_anonymous() ) { // Filter ...


3

If you prefer simple template files, you can do that with custom comment callbacks too. Call wp_list_comments() with a custom callback handler: wp_list_comments( array( 'callback' => 'custom_comment_callback', 'style' => 'ol' ) ); Now make that callback function very simple: function custom_comment_callback( ...


3

wp_insert_comment() is low level function, it only saves passed data without concern for what it contains. If you are looking to replicate sanitizing WP does on comment data (totally good idea :) you are probably looking for higher level wp_new_comment().


2

If you want to be rid of comments on your site, one option is to remove the code from your theme files. You would need to search single.php, home.php, page.php, etc. within wp-content/themes/*your-active-theme* and find: <? php comments_template(); ?> Remove that and the comments section should disappear. NOTE: this change will be undone if you ...


2

This question is very hard to understand but I think that you might need to put wp_reset_query() or wp_reset_postdata() after your Loop (after endwhile;) to to reset the loop and/or the $post variable.


2

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.


2

In the default usage this is impossible due to the nature of the default comment walker which always directly outputs. But the function allows to provide a custom walker. Further reading about custom walkers: Codex Class reference example custom walker class You could also use output buffering to save it into a variable (this is considered to be dirty): ...


2

When it comes to retrieve posts, it's supposed to call WP_Query. WP_Query has an argument called meta_query but it doesn't have comment_query. So it might need a trick to achieve what you want, $args = array(); $args['feed'] = 1; $args['withcomments'] = 1; $args['author'] = 1; //author id. $query = new WP_Query($args); $posts = $query->posts; //do what ...


2

You don't need a form to submit a comment to the wp-comments-post.php file, or to send a pingback or trackback. Spammers don't use forms, they simply send their spam directly. Removing the form doesn't "turn off" comments. To do that, go to the Posts screen, and use the Quick Edit to actually disable comments and trackbacks for the various posts. Also visit ...


2

Debug ideas: You could try to see if this has any effect: add_filter( 'bp_core_fetch_avatar_no_grav', '__return_true' ); But you should check out the parameters that go through the bp_core_fetch_avatar filter to see if they are correct (untested): add_filter( 'bp_core_fetch_avatar', 'my_bp_core_fetch_avatar', 99, 9 ); function my_bp_core_fetch_avatar( ...


2

You are using comments_template which prints out the comments and returns nothing you need to capture the comments template so try this: function get_comments_template(){ ob_start(); comments_template(); return ob_get_clean(); } and change this line: $result .= comments_template(); //Append the comments template to the result to $result ...


2

Well, this is partly true and partly false. When you trash a post, everything that is tied to it is also trashed. This means, if you untrash the post, the comments etc. are untrashed as well. However, comments and other stuff is not handled as if they were trashed directly (i.e., on the Comments page in your WordPress Admin). If you directly trash a ...


2

That table is essentially the same as for all of the other "meta" tables in the WordPress architecture. It holds misc. bits of extra, usually optional, information about the associated post, user, or in this case comment. You can store whatever information you need to add to a comment-- perhaps a plugin wants to implement "abuse" flags, or comment upvotes. ...


2

wp_list_comments() accepts a walker in the array of its first parameter. This is a class that renders the output. If you don’t provide one, the default class will be used, Walker_Comment. You can find it in wp-includes/comment-template.php. To change the complete comment list out, create a custom walker in your functions.php which extends the default class: ...



Only top voted, non community-wiki answers of a minimum length are eligible