How Can I display the Current Logged-In User’s Comment at the Top of the Comments Section in WordPress?

Alright, I figured it out. Thanks for all the direction everyone! <?php global $current_user,$post; $args = array(‘user_id’ => $current_user->ID,’post_id’ => $post->ID); // The Query $comments_query = new WP_Comment_Query; $comments = $comments_query->query( $args ); // Comment Loop if ( $comments ) { foreach ( $comments as $comment ) { echo ‘<p>’ . $comment->comment_content . ‘</p>’; } … Read more

How to get the 5 most recent comments and each comment 5 most recent replies (children)

To list the most recent (5) comments you can use this code : $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) // NUMBER OF CHARACTERS AS com_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) WHERE comment_approved = ‘1’ AND comment_type=”” AND post_password = ” ORDER BY … Read more

Change author, disable comments, enable trackbacks for all items in library

You have to run SQL query to do this. Put this code into your functions.php once, run your website and then delete it. global $wpdb; $author = 1; $comment_status=”closed”; $ping_status=”open”; $query = sprintf( ‘UPDATE %sposts SET `author` = %d, `comment_status` = %s, `ping_status` = %s’, $wpdb->prefix, $author, $comment_status, $ping_status ); $wpdb->query($query); Or run it directly … Read more

Comments pagination on author page

Make sure you’ve set the paged parameter in your query, below is shown how to do that. <?php $paged = ( get_query_var( ‘paged’ ) ) ? get_query_var( ‘paged’ ) : 1; $args = array( ‘posts_per_page’ => 3, ‘paged’ => $paged ); $the_query = new WP_Query( $args ); ?> For more information about pagination have a … Read more

What is wrong with this? [closed]

The error is in the syntax; there’s a semicolon after the if condition. Try this: <?php $page_comment = get_query_var(‘cpage’); if ($page_comment > 0): ?> test <?php endif; ?> Alternative PHP syntax: <?php $page_comment = get_query_var(‘cpage’); if ($page_comment > 0){ ?> test <?php } ?>