Viewing 6 replies - 31 through 36 (of 36 total)
  • Plugin Author rahulbrilliant2004

    (@rahulbrilliant2004)

    Hi

    We havent tested it out with buddy press yet. We will test it out and get back to you ASAP

    Hi Rahul,

    Have just downloaded your WP like dislike counter plugin. I am trying to get a like/dislike (with counter) under each wordpress comment but am unsure where to put

    <?php if(function_exists('like_counter_c')) { like_counter_c("Like"); } ?>
    <?php if(function_exists('dislike_counter_c')) {dislike_counter_c("Dislike"); } ?>

    Firstly do you put it in comments.php or loop.php and secondly could you advise where it should go within that?

    Thanks in advance,
    Paul

    Plugin Author rahulbrilliant2004

    (@rahulbrilliant2004)

    To get a like/dislike (with counter) under each WordPress comment.
    You have to put like dislike php code inside comments.php file.

    And if you are using custom comments.php then you can add theses php code after the comment text.

    Please have a look over the suggestion and let us know if you have any issue/query regarding this.

    Thanks for the reply Rahul, I’m still having problems though.

    Here is my code from comments.php

    <?php if (have_comments()) { ?>
      <div id="commentspost"><a name="commentspost"></a>
    	<ol class="normalComments"><?php wp_list_comments('type=all&avatar_size=60'); ?></ol>
    	</div><!-- end #commentspost -->
    
    <?php if ('closed' == $post->comment_status) : ?>
    <?php endif; ?>
    
     <?php }
     else { // this is displayed if there are no comments so far ?>
    
    	<?php if ('open' == $post->comment_status) { ?>
    		<!-- If comments are open, but there are no comments. -->
    <div id="commentspost">
    	<h2 class="title">0 <?php _e('Comments', 'wpzoom'); ?></h2>
      <p><?php _e('You can be the first one to leave a comment', 'wpzoom'); ?>.</p>
    </div>
    	 <?php } else { // comments are closed ?>
    		<!-- If comments are closed. -->
    	<?php } ?>
    <?php } ?>

    Here is my code from page.php

    <?php
    			wp_reset_query();
    
    			if ( have_posts() ) :
    
    				while ( have_posts() ) :
    
    					the_post();
    
    					?><h1><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1>
                                            <h2 class="title"><?php comment_type_count();?> <?php _e('Comments', 'wpzoom'); ?></h2>
    
    					<p class="postmetadata"><?php edit_post_link( __('EDIT', 'wpzoom'), '', ''); ?></p> 
    
    					<div class="postcontent">
    
    <?php comments_template(); ?> <?php
    
    				endwhile;

    I realise comments.php would make more sense to enter the like/dislike counter code but the code which refers to the comments in page.php looks more familiar from previous comments on here.

    If you could tell me which and where exactly the code should go that would be awesome!

    Thanks in advance!

    After further research I’ve been advised I need to alter the wp_list_comments function… but have no idea how to do this?

    Can you help with that Rahul? And even better how to insert the above code into that function?

    Plugin Author tikendramaitry

    (@tikendramaitry)

    Hi All,

    If you want to use the like dislike counter button with your comment section you have to use wp_list_comments like this instead simple wp_list_comments:

    <?php wp_list_comments('type=comment&callback=my_custom_comments'); ?>

    In this we are using callback to show comment list. In particular we are using my_custom_comments as my callback function. And in this callback function we can use like dislike button code. Here I have used the template code for like dislike buttons below <?php comment_text() ?>

    In functions.php use below function:

    function my_custom_comment($comment, $args, $depth) {
    
    		$GLOBALS['comment'] = $comment;
    
    		extract($args, EXTR_SKIP);
    
    		if ( 'div' == $args['style'] ) {
    
    			$tag = 'div';
    
    			$add_below = 'comment';
    
    		} else {
    
    			$tag = 'li';
    
    			$add_below = 'div-comment';
    
    		}
    
    ?>
    
    		<<?php echo $tag ?> <?php comment_class(empty( $args['has_children'] ) ? '' : 'parent') ?> id="comment-<?php comment_ID() ?>">
    
    		<?php if ( 'div' != $args['style'] ) : ?>
    
    		<div id="comment-body-top"></div>
    
    		<div id="div-comment-<?php comment_ID() ?>" class="comment-body">
    
    		<?php endif; ?>
    
    		<div class="comment-author vcard">
    
    		<?php if ($args['avatar_size'] != 0) echo get_avatar( $comment, 50 ); ?>
    
    		<?php printf(__('<cite class="fn">%s</cite>'), get_comment_author_link()) ?>
    
    		</div>		
    
    		<div class="comment-meta commentmetadata"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>">
    
    			<?php
    
    				/* translators: 1: date, 2: time */
    
    				printf( __('%1$s at %2$s'), get_comment_date(),  get_comment_time()) ?></a><?php edit_comment_link(__('(Edit)'),'  ','' );
    
    			?>
    
    		</div>
    
    		<div class="comment_txt"> <?php comment_text() ?> </div>   
    
    		<!-- here to copy and paste like dislike button functions -->
    		<?php
    		if(function_exists('like_counter_c')) { like_counter_c("text for like"); }
    		if(function_exists('dislike_counter_c')) { dislike_counter_c("text for dislike"); }
    		?>
    		<!-- here to copy and paste like dislike button functions -->
    
    		<?php if ($comment->comment_approved == '0') : ?>
    
    				<em class="comment-awaiting-moderation"><?php _e('Your comment is awaiting moderation.') ?></em>
    
    		<?php endif; ?>
    
    		<div class="reply">
    
    		<?php comment_reply_link(array_merge( $args, array('add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
    
    		</div>
    
    		<?php if ( 'div' != $args['style'] ) : ?>
    
    		</div>
    
    		<div id="comment-body-bottom"></div>
    
    		<?php endif; ?>
    
    <?php
    
            }
    
    ?>

    You can refer Function Reference/wp list comments

    cheers ??

Viewing 6 replies - 31 through 36 (of 36 total)
  • The topic ‘[Plugin: Like Dislike Counter] What do you mean?’ is closed to new replies.