• Resolved edow

    (@edow)


    Hi,

    I would like to remove the text field from the comment form. The idea is that users can vote if they like the post or not. The like/unlike option must be done with radio buttons in a custom field (that would be the next problem).

    But first: How can I remove the text field? I don’t want it hidden, but entirely removed. What is the best practice for this? I can’t find a decent solution.

    Hopefully anyone can help me with this.

Viewing 4 replies - 46 through 49 (of 49 total)
  • Moderator bcworkz

    (@bcworkz)

    Your implementation is slightly different than what I had in mind, but carried out correctly, so it’s all good. Your code looks fine, and the fact it’s working confirms it. If it is doing exactly what you want, there is no need to change anything. You will not have any future problems. Well done!

    I’m pleased you finally got what you wanted and were able to learn along the way. Your command of English is excellent. While you did misunderstand me a few times, I am very bad at communicating clearly with non-native English speakers, so the fault is mine, not yours. Even native speakers often do not understand me!

    Thread Starter edow

    (@edow)

    Your instructions were very clear! I’m also glad it worked out as I wanted. Thanks!

    Thread Starter edow

    (@edow)

    I feel guilty to ask something again in this topic, but it seems to me this is the best place to ask it.

    As seen above I use this code to show the post score:

    <?php
    $counts = aigoo_get_score();
    			extract( $counts );  //restores compacted variables
    
    <span>+'.$score.'</span>
    ?>

    The following code is showing the latest 5 posts with the most comments in a specific category on my homepage:

    <?php
    			$popular = new WP_Query( array(
    				'post_type'             => array( 'post' ),
    				'showposts'             => 5,
    				'cat'                   => 'activiteit',
    				'ignore_sticky_posts'   => true,
    				'orderby'               => 'comment_count',
    				'order'                 => 'dsc',
    				'date_query' => array(
    					array(
    						'after' => '0',
    					),
    				),
    			) );
    		?>
    		<?php while ( $popular->have_posts() ): $popular->the_post(); ?>
    			<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a> (<?php comments_number( 'Nu stemmen!', '1', '%' ); ?>)</li>
    		<?php endwhile; ?>

    How can I make it happen that instead of showing the posts with the most comments it shows the posts with the highest voted comments on my homepage?

    I don’t know if it’s even possible.

    To be complete, this is in my functions.php:

    <?php
    /* Display likes/unlikes */
    function aigoo_get_score() {
       $comments = get_comments( array('post_id' => get_the_ID(),) );
    			$likes = array();
    			$unlikes = array();
    			foreach( $comments as $comment ) {
    				if('unlike' == $comment->comment_content ) $unlikes[] = $comment;
    					else $likes[] = $comment;
    			}
        $likescore = count( $likes );
    	$unlikescore = count( $unlikes );
    	$score = count($likes) - count($unlikes);
    	$totalvotes = count($likes) + count($unlikes);
    	return compact('likes', 'unlikes', 'likescore', 'unlikescore', 'score', 'totalvotes');
    }
    ?>

    If you require assistance then please post a new topic. I am now closing this 3 month old resolved topic as it references an older version of WordPress.

Viewing 4 replies - 46 through 49 (of 49 total)

The topic ‘Remove text field from comment form’ is closed to new replies.