Adding comments to my custom theme

While much of comments implementation became simpler in modern WP versions, it still isn’t quite make-comments-happen button. You will need to put together this part of template, most of related functionality is handled by: wp_list_comments() comment_form() Check native WP themes for complete start to end implementation, although they tend to be a little bulky.

Show Social Sharing Buttons And Facebook Comments In Lightbox Modal Dialog (Image Overlay)?

You can show Facebook and Pinterest sharing tools on the Nextgen lightbox with this tool: http://sharemygallery.com You want a facebook comment box. Unfortunately, this doesn’t do that. This plugin puts Facebook and Pinterest sharing buttons at the bottom of the image browser. It may help you if you just want to get people stared sharing … Read more

Custom setup of wordpress comments that are displayed

Try adding the following code to your comments.php template file (where you want the “next page”https://wordpress.stackexchange.com/”prev page” links displayed): <?php paginate_comments_links(); ?> This should enable multiple pages for your comments. Also, check out this Codex page (paginate_comments_links) for more information. Hope this helps 😉

Show comment number per author per day

You can try this query that counts user comments by using the user_id field in the comments table as a filter: function count_user_comments_today( $uid ){ global $wpdb; $today = date(‘Y-m-d’); $tomorrow = date(‘Y-m-d’, time() + 86400); $count = $wpdb->get_var( $wpdb->prepare(“SELECT COUNT(*) FROM {$wpdb->comments} WHERE user_id = %d AND comment_date >= %s AND comment_date < %s … Read more

Get comments only for certain specific users in template file

You can try to modify the query using the comments_clauses filter: $args = array( ‘user_id’ => 0 ); add_filter( ‘comments_clauses’, ‘custom_comments_clauses’); $comments = get_comments( $args ); remove_filter( ‘comments_clauses’, ‘custom_comments_clauses’); function custom_comments_clauses( $clauses ){ $clauses[‘where’] = str_replace( ‘user_id = 0’, ‘user_id IN (1, 2, 3)’, $clauses[‘where’] ); return $clauses; } Update: You could also add a … Read more

How to get posts and comments amount per hour, per year and per month?

For comments: function count_comments_in_period( $date_from, $date_to ){ global $wpdb; $count = $wpdb->get_var( $wpdb->prepare(“SELECT COUNT(*) FROM {$wpdb->comments} WHERE comment_date >= %s AND comment_date < %s “, $date_from, $date_to)); return $count; } Just use dates in yyyy-mm-dd format. For posts: function count_posts_in_period( $date_from, $date_to ){ global $wpdb; $count = $wpdb->get_var( $wpdb->prepare(“SELECT COUNT(*) FROM {$wpdb->posts} WHERE post_date >= … Read more

Safely editing core files

There is no “safe” way to edit core files; if you do you will need to check and repeat the edition after every update. Not recommended at all. Instead of editing core files, you could use any of the actions and filters available. For example, pre_comment_on_post (example code not tested): add_action( ‘pre_comment_on_post’, function( $post_id ) … Read more

Minimum allowed comment length only on a specific page

is_page() is not available at that point try using global $post that way the post ID should be available for comparison. add_filter( ‘preprocess_comment’, ‘wpb_preprocess_comment’ ); function wpb_preprocess_comment($comment) { global $post; if ((strlen( $comment[‘comment_content’] ) < 60 ) && ($post->ID == 42)) { wp_die(‘Minimum allowed comment length is 60 characters.’); } return $comment; }

is pre_get_comments not working?

I don’t see any reason why pre_get_comments would not be working, it’s still in core, however… you’ve got a few problems in your code – do_action_ref_array is what core calls to trigger the action, you add your own functions to the action queue via add_action. orderby is the field name you want to order by, … Read more