Resetting comment count

Try this code: WARNING: THIS IS JUST PSEUDOCODE! $entries = $wpdb->get_results(“SELECT * FROM wp_posts WHERE post_type IN (‘post’, ‘page’)”); foreach($entries as $entry) { $post_id = $entry->ID; $comment_count = $wpdb->get_var(“SELECT COUNT(*) AS comment_cnt FROM wp_comments WHERE comment_post_ID = ‘$post_id’ AND comment_approved = ‘1’”); $wpdb->query(“UPDATE wp_posts SET comment_count=”$comment_count” WHERE ID = ‘$post_id'”); } Or you might want … Read more

Enable Submit Comment Without Page Reload (Using Ajax)?

Save the following javascrip file wpse54189-ajax-comments.js inside your plug-in folder – say plugins/plug-in-name/js (or if this must go your theme, in your theme folder). /* * jQuery autoResize (textarea auto-resizer) * @copyright James Padolsey http://james.padolsey.com * @version 1.04 */ (function(a){a.fn.autoResize=function(j){var b=a.extend({onResize:function(){},animate:true,animateDuration:150,animateCallback:function(){},extraSpace:20,limit:1000},j);this.filter(‘textarea’).each(function(){var c=a(this).css({resize:’none’,’overflow-y’:’hidden’}),k=c.height(),f=(function(){var l=[‘height’,’width’,’lineHeight’,’textDecoration’,’letterSpacing’],h={};a.each(l,function(d,e){h[e]=c.css(e)});return c.clone().removeAttr(‘id’).removeAttr(‘name’).css({position:’absolute’,top:0,left:-9999}).css(h).attr(‘tabIndex’,’-1′).insertBefore(c)})(),i=null,g=function(){f.height(0).val(a(this).val()).scrollTop(10000);var d=Math.max(f.scrollTop(),k)+b.extraSpace,e=a(this).add(f);if(i===d){return}i=d;if(d>=b.limit){a(this).css(‘overflow-y’,”);return}b.onResize.call(this);b.animate&&c.css(‘display’)===’block’?e.stop().animate({height:d},b.animateDuration,b.animateCallback):e.height(d)};c.unbind(‘.dynSiz’).bind(‘keyup.dynSiz’,g).bind(‘keydown.dynSiz’,g).bind(‘change.dynSiz’,g)});return this}})(jQuery); /* * Source: wp-comment-master WordPress Plugin * URL: http://wordpress.org/extend/plugins/wp-comment-master/ … Read more

Using WordPress’ WYSIWYG for comments

Give this a shot: <?php /* Add WYSISYG editor to comment form. */ add_filter( ‘comment_form_field_comment’, ‘wpse_64243_comment_editor’ ); function wpse_64243_comment_editor( $field ) { if (!is_single()) return $field; //only on single post pages. global $post; ob_start(); wp_editor( ”, ‘comment’, array( ‘textarea_rows’ => 15 ) ); $editor = ob_get_contents(); ob_end_clean(); //make sure comment media is attached to parent … Read more

How to enable comments for pending and draft posts?

The following enables the default meta box for draft and pending posts (in the portfolio post_type): add_action( ‘admin_init’, ‘wpse_74018_enable_draft_comments’ ); /** * Add Comments Meta Box if CPT is ‘draft’ or ‘pending’ */ function wpse_74018_enable_draft_comments() { if( isset( $_GET[‘post’] ) ) { $post_id = absint( $_GET[‘post’] ); $post = get_post( $post_id ); if ( ‘draft’ … Read more

How to wrap submit button of comment form with div

We can use comment_form function’s submit_button parameter to change submit button HTML. Default HTML for submit_button is <input name=”%1$s” type=”submit” id=”%2$s” class=”%3$s” value=”%4$s” /> You can change your code like this. $comments_args = array( …. ‘submit_button’ => ‘<div class=”form-group”> <input name=”%1$s” type=”submit” id=”%2$s” class=”%3$s” value=”%4$s” /> </div>’ …. ); Update: Regarding %1$s , %2$s and … Read more

How to add a class to the comment submit button?

If you check out the source of the function comment_form(), you’ll see it doesn’t even print a class on the input; <input name=”submit” type=”submit” id=”<?php echo esc_attr( $args[‘id_submit’] ); ?>” value=”<?php echo esc_attr( $args[‘label_submit’] ); ?>” /> I’m guessing you need to add a class for styling? Why not modify your CSS to just; input.submit, … Read more

Importing old Disqus comments into WordPress

Without having a sample xml file, it’s impossible to try to debug that plugin and see where it is failing. Tried to search if some innocent soul left a file hanging on the internets, but nope. But one can see what others are saying: The nightmare that is Disqus export, and import into WordPress. September … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)