New answers tagged

0

I use simply this, as i couldnt find other.. add_action('plugins_loaded', 'Check_commentt'); //or directly execute Check_commentt() function Check_commentt(){ if (isset($_POST['author']) && isset($_POST['email'])){ //do something } }


0

It seems you need to change the Collation for the wp_comments and wp_commentmeta tables on your Live server to utf8mb4_unicode_ci.


0

Open your style.css on your template folder and add this: .authorstyle { background-color: #B3FFCC !important; } Now open your comments.php and find code that should look something like this: <li <?php echo $oddcomment; ?>id="comment-<?php comment_ID() ?>"></li> and replace it with this code: <li class="<?php if ...


0

Code snippet for displaying posts with most comments: <?php $result = $wpdb->get_results("SELECT comment_count, ID, post_title FROM $wpdb->posts ORDER BY comment_count DESC LIMIT 0 , 10"); // NUMBER OF POSTS foreach ($result as $topten) { $postid = $topten->ID; $title = $topten->post_title; $commentcount = ...


0

If you want to display only recent comments on posts without using a plugin, use the following code in your theme's template file: <?php global $wpdb; $sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type,comment_author_url, SUBSTRING(comment_content,1,50) ...


0

If you just want to know how they do it, one idea is these spammers mostly use scripts that bypass your comment form, and even if it is not there, the script directly access your site's wp-comments-post.php and write on it directly.


0

Comment spams can be reduced by eliminating all direct requests to your blog's comments-post.php file. This will block the automated scripts and will not allow them to bypass your comment form. You can achieve it with placing this php function in your functions.php file function check_referrer() { if (!isset($_SERVER['HTTP_REFERER']) || ...


0

Rather than hacking the comment system into doing something it isn't meant to do, I'd create a Custom Post Type for the user generated content and expose a form on the front-end of the site that allows the user to generate content of that CPT's type. This can be done pretty easily with a number of form plugins, such as Gravity Forms, Ninja Forms or Caldera ...


2

Here are some options on how we can override the native layout for each comment: Approach #1 - Overriding start_el() with a custom walker Let's define our custom wpse comment format: // Arguments for wp_list_comments() $args = [ 'style' => 'ol', 'format' => 'html5', 'short_ping' => true, ]; // Use our custom walker if ...


0

paste this in your theme's functions.php: add_action( 'comment_form_before', 'my_comment_form_before' ); function my_comment_form_before() { ob_start(); } add_action( 'comment_form_after', 'my_comment_form_after' ); function my_comment_form_after() { $html = ob_get_clean(); $html = preg_replace( '/wp-comments-post.php"/', ...


-1

Looked it up on Disqus' website and found a link that may answer your question. You will need to install the disqus plugin to do it automatically, or use the Tools > Export feature to export posts from which Disqus can pull comments. Importing to Disqus


3

We could rewrite: wp_list_comments( array( 'callback' => 'bootstrap_comment_callback', )); with the null walker parameter: wp_list_comments( array( 'walker' => null, 'callback' => 'bootstrap_comment_callback', )); which means we are using the default Walker_Comment class: wp_list_comments( array( 'walker' ...


0

Ok I feel stupid now. The problem was that for whatever reason some of the posts had comments disabled. I did not know that the only place where they could be toggled was under "Quick Edit". Problem solved...


0

Now it works. Im very grateful to jgraup! All that I needed to change is to add $icon = $GLOBALS[$icon_var]; and change the $menu_list structure as jgraup recommended. Even there is no need for third-party changes. The final code: function sidebar_menu() { $menu_name = 'sidebar_pages'; if (($locations = get_nav_menu_locations()) && ...


0

You need to call global $variable; before you can use the variable. Try the code below instead for that line. // setup your global scope here global $icon_var; // set the new value in global scope $icon_var = get_post_meta($menu_item->ID, '_menu_item_custom', true); // then use the variable $menu_list .= "\t\t\t\t\t<li><a ...


0

I believe the easiest way to do that will be with javascript. Something that will navigate at each comment list and show only last button. Something like: jQuery(document).ready( function($){ //Hide all buttons $('.comments li .reply-button').hide(0); //Navigate through all comments $('.comments li').each( function() { //Lets ...


3

Lets try the following: By default, all posts are returned regardless of comment_status, so lets run the main query as normal, that is, query all posts regardless of comment_status. We will also run a small, but very lean secondary query where we will get all posts which have a comment_status of closed which have a meta value of not yes The returned ...


3

If you need to modify the max depth, you could use the thread_comments_depth_max filter: /** * Set max comments depth to 15 on the discussion settings page */ add_filter( 'thread_comments_depth_max', function( $max ) { return 15; } ); then the dropdown on the discussion settings page will show the range 1 - 15. But I can imagine very deep comment ...


0

This is generaly a long term bad idea equivalent to forking the plugin even if you don't change a single line of code in them as the plugin might require those commented out styles/scripts in its next version (or your freind will change setting that require it). If you are not happy with how the plugin works, contact his author and ask them to fix it, ...


0

Install Query Monitor to show your scripts and styles (#qm-assets) - specifically the ID used to register the scripts/styles. Then hook wp_print_scripts and use wp_dequeue_script() to remove it before it outputs. /** * Dequeue the jQuery UI script. * * Hooked to the wp_print_scripts action, with a late priority (100), * so that it is after the script ...


0

You could try this, must be used in the loop: <?php // type = comment will only get "real" comments, no ping-/trackbacks $comments = get_comments(array('type' => 'comment')); $threads = 0; foreach($comments as $comment) { // if the comment has no parent, it´s the first of a thread if($comment->parent == '') { $threads++; } } ...


0

This function allows the user to submit a comment without any text in the textarea. Then all you need to do is hide the comment textarea with some display:none; css. function rei_preprocess_comment($comment_data) { if ($comment_data['comment_content'] == '%dummy-text%') { $comment_data['comment_content'] = ''; // replace dummy text. } ...


-1

This is how to submit a comment without any text in the textarea... function rei_preprocess_comment($comment_data) { if ($comment_data['comment_content'] == '%dummy-text%') { $comment_data['comment_content'] = ''; // replace dummy text. } return $comment_data; } add_filter('preprocess_comment', 'rei_preprocess_comment'); function ...


0

I did it the long way, with help from a related WordPress.org support thread: add_action('comment_post', 'notify_author_of_reply', 10, 2); function notify_author_of_reply($comment_id, $approved){ $comment = get_comment($comment_id); $post_id = $comment->comment_post_ID; $post = get_post($post_id); if($approved && (get_post_type( ...


0

) first thanks a lot to @swisspidy and the suggestion to modify $_POST on the init hook. but after a bit of more thinking and looking at the code i took a different approach. instead of fixing things afterwards, after the form submit, i decided to fix things via jQuery during the form submit and do the necessary checks about the comment input field there. ...


1

Have a look at the Codex about "Using Gravatars". There you´ll find a part about "Checking for the Existence of a Gravatar" which works like this: The trick to do this is to specify "404" as the default. In this case, the gravatar service will return a 404 error if no gravatar exists, instead of returning some default image. A real image will get a 200 ...



Top 50 recent answers are included