Notifications
Clear all

"comments_array" hook in functions.php has no effect in newer versions

5 Posts
2 Users
0 Likes
1,050 Views
(@gravityswitch)
Member Customer
Joined: 8 years ago
Posts: 6
Topic starter  

Client site is on wpDiscuz Version 5.3.2 . We need to have the order of comments for certain posts reversed, so used the following. This worked fine at one point but has broken in more recent versions of wpDiscuz. This is core WP functionality, so wpDiscuz ought to be compatible with it if possible? Note that more ordinary values for the priority parameter also did not work.

function reverse_comments( $comments , $post_id ) {
$thepost = get_post($post_id);
if ($thepost->post_type == "reviews" && $thepost->post_parent == 0) {
return array_reverse( $comments );
}
else {
return ( $comments );
}

}
add_filter( 'comments_array' , 'reverse_comments' , 99999, 2 );



   
Quote
Astghik
(@astgh)
Illustrious Member Admin
Joined: 6 years ago
Posts: 5872
 

Hi Jessa Tower,

I'll ask this question to the plugin developers and let you know asap. 


   
ReplyQuote
Astghik
(@astgh)
Illustrious Member Admin
Joined: 6 years ago
Posts: 5872
 

@gravityswitch,

you cannot use the code. You should use the code you've mentioned.

You should use the wpdiscuz_comment_list_args hook, and set true value for reverse_top_level


   
ReplyQuote
(@gravityswitch)
Member Customer
Joined: 8 years ago
Posts: 6
Topic starter  

Can you tell me why this code isn't working? The "Reverse child comments order" setting in wpDiscuz is NOT set, if that means anything. Even stripping out the conditionals I need for this particular use case, this code does absolutely nothing. I also tried a version posted on this board using array_merge rather than setting reverse_top_level directly, same result.

function set_comment_args($default_args){
$new_args = $default_args;
$new_args['reverse_top_level'] = TRUE;
return $new_args;
}
add_filter('wpdiscuz_comment_list_args', 'set_comment_args');

   
ReplyQuote
Astghik
(@astgh)
Illustrious Member Admin
Joined: 6 years ago
Posts: 5872
 

@gravityswitch

We've just checked the code above and it works fine. Please try to delete caches before checking. 


   
ReplyQuote
Share:
Scroll to top