“Discussion” checkboxes unchecked by default on pages? [duplicate]

You can re-register the “page” post type and leave out the comments capability. add_action( ‘init’, ‘my_new_page_type’ ); function my_new_page_type() { register_post_type( ‘page’, array( ‘labels’ => array( ‘name_admin_bar’ => _x( ‘Page’, ‘add new on admin bar’ ), ), ‘public’ => true, ‘publicly_queryable’ => false, ‘_builtin’ => true, /* internal use only. don’t use this when registering … Read more

How to hide trackbacks on wp-admin/edit-comments.php

While this is not impossible, this is very likely to have ton of edge cases and backfire in some. In a nutshell comments are retrieved with comment query, which can be adjusted with something like this (if in admin and comment type not specified then only fetch normal comments): add_action( ‘pre_get_comments’, ‘exclude_pings’ ); function exclude_pings( … Read more

get_comments not working consistantly with post_id

Turns out it was my use of the language plugin (polylang)… When I call the comments it adds a language filter: ‘lang’ => $currentLang So I had to explicitly override that: get_comments(array(‘post_id’=>31, ‘lang’ => $targetLang)); I still don’t know why I was sometimes able to get the other comments without this.

I wish to remove, disable or hide the comment authors’ links to their sites from my home page

Add following code snippet in functions.php. (in your themefolder) Edit new code: – This should do the trick, sorry for the delay. /** * Remove post author link on comments * * @return string $author */ function wpse218025_remove_comment_author_link( $return, $author, $comment_ID ) { return $author; } add_filter( ‘get_comment_author_link’, ‘wpse218025_remove_comment_author_link’, 10, 3 ); Note: you can … Read more

Comments offset

<?php global $wp_query, $post; $comments_arr = $wp_query->comments; $comments_arr = sort( $comments_arr); $comments_arr = array_pop( $comments_arr ); $comments_arr = usort($comment_arr, ‘comment_comparator’); $comment_count = get_comment_count($post->ID); ?> <h3 id=”comments-title”><?php printf( _n( ‘One Response to %2$s’, ‘%1$s Responses to %2$s’, get_comments_number(), ‘YOUR_THEMES_TEXTDOMAIN’ ), number_format_i18n( get_comments_number() ), ‘<em>’ . get_the_title() . ‘</em>’ ); ?></h3> if ( have_comments() ) : ?><ul … Read more

have_comments not true for logged out visitors?

Probably your web-server user does not have permissions to create new files. I believe that WordPress caches comments on pages and posts for not logged users, so that only authenticated users get fresh comments list. When logged out user inputs a comment, the list gets updated with his comment too, which brings them the whole … Read more

Filtering the Admin Comments List to Show Only Comments from the Current User?

Either of these 3 will help you: //Before getting the comments, on the WP_Comment_Query object for each comment add_action(‘pre_get_comments’, ‘wpse56652_filt_comm’); //Applied on the comments SQL Query, you can modify the ‘Where’ part of the query add_filter(‘comments_clauses’, ‘wpse56652_filt_comm’); //After the comments are fetched, you can modify the comments array add_filter(‘the_comments’, ‘wpse56652_filt_comm’); function wpse56652_filt_comm($param) { //access the … Read more

Cancel comment filter?

You are certainly on the right track. You can create a plugin (create a directory in “wp-content/plugins” and create a php file with the same name as the folder) with the following code: function wpse_33944_filter_handler( $approved , $commentdata ){ if(strlen($commentdata[comment_content]) > 5) { return false; } return true; } add_filter( ‘pre_comment_approved’ , ‘wpse_33944_filter_handler’ , ’99’, … Read more