Display custom posts, ordered by most commented, without duplicates

Currently, it looks like you are looping through comments and then querying the posts from there. Could you use the comment_count order by parameter directly in the posts query itself? For example: <?php $post_args = array( ‘post_type’ => ‘portfolio’, ‘posts_per_page’ => 1, ‘orderby’ => ‘comment_count’ ); $posts = get_posts($post_args); foreach ($posts as $post) : setup_postdata($post); … Read more

Force to show all fields in comment forms to the logged-in users

you can paste the code below in your theme functions.php file, it should generate almost the same comment form for logged in and logged out users add_filter( “comment_form_fields”, function( $comment_fields ) { if( is_user_logged_in() ) { // Get an array of field names, excluding the textarea $comment_field_keys = array_diff( array_keys( $comment_fields ), array( ‘comment’ ) … Read more

How can i display pagination in custom comment list?

You should use append paginate_comments_links() into $output like so: add_shortcode ( ‘show_recent_comments’, ‘show_recent_comments_handler’ ); function show_recent_comments_handler( $atts, $content = null ) { extract( shortcode_atts( array( “count” => 20, “pretty_permalink” => 0 ), $atts )); $output=””; // this holds the output if ( is_user_logged_in() ) { global $current_user; get_currentuserinfo(); $args = array( ‘user_id’ => $current_user->ID, ‘number’ … Read more

I would like to count number of comments after 5 days ago

thank you for WebElain to help me. This answer driving me to the right request. Now it’s ok. It is an object indead and I use something more simple with get_comments () query with parameter count enabled. the final code is like this : #!/usr/bin/php <?php if ( ! defined(‘ABSPATH’) ) { /** Set up … Read more

How do I refresh “Post Last Modified Time”, as long as comment is updated to Approve status?

It’s easy, you can just use different hook to perform same action. add_action( ‘comment_approved_’, ‘update_post_time’, 99, 2); // this will fire when comment is approved regardless of comment type Last underscore in action name is important comment_approved_ as normally after it goes comment-type if you need to hook to approval to specific comment types. See … Read more

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