Search
Close
AI Search
Classic Search
 Search Phrase:
 Search Type:
Advanced search options
 Search in Forums:
 Search in date period:

 Sort Search Results by:

AI Assistant
Notifications
Clear all

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

5 Posts
2 Users
0 Reactions
2,353 Views
(@gravityswitch)
Member Customer
Joined: 10 years ago
Posts: 6
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
  [#4179]

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: 8 years ago
Posts: 6645
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

Hi Jessa Tower,

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



   
ReplyQuote
Astghik
(@astgh)
Illustrious Member Admin
Joined: 8 years ago
Posts: 6645
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

@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: 10 years ago
Posts: 6
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

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: 8 years ago
Posts: 6645
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

@gravityswitch

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



   
ReplyQuote
Share:
Scroll to top