wpDiscuz - WordPress Comment Plugin
Conditionally displ...
 
Share:
Notifications
Clear all

Question Conditionally displaying comments

7 Posts
2 Users
0 Likes
117 Views
Posts: 4
Topic starter
(@solodevelops)
Active Member
Joined: 3 weeks ago

Currently on my website I have comments enabled to load on my "wall pages", which are essentially posts. Each wall page is saved as an entry to a unique database and each entry has a unique ID ("id" column). The comments are all saved in the default wp_comments table and I've added a "wall_post_id" column to them, so that the column updates with the value of the id of the wall page for each comment entry.

Β 

I want to only display comments that have matching "wall_post_id" with the id of the current "wall page". I don't know which file to manipulate in the file manager.Β 

6 Replies
Asti
Posts: 6223
 Asti
Support
(@asti)
Illustrious Member
Joined: 6 years ago

Hi Solodevelops,

As you may know, wpDiscuz is a native comment system and it uses the same WordPress database tables to store the comments. So this is not a wpDiscuz-related question.

You should use theΒ pre_get_comments hook to make it work as you need. More info here: https://developer.wordpress.org/reference/hooks/pre_get_comments/

Reply
Posts: 4
Topic starter
(@solodevelops)
Active Member
Joined: 3 weeks ago

Hey Asti,Β 

Β 

Thanks for getting back to me. I'll look into using the pre_get_comments hook.

Β 

Looking at the files within the "wpdiscuz" folder, in plugins, I see one or two files with comment retrieving functionality. If I was to insert the pre_get_comments logic somewhere, I assume it would be outside of the wpdiscuz folder, perhaps in my functions.php?

Β 

Thanks

Reply
4 Replies
Asti
 Asti
Support
(@asti)
Joined: 6 years ago

Illustrious Member
Posts: 6223

@solodevelops,

Yes sure, you should add the code in the active theme functions.php file.Β 

Reply
(@solodevelops)
Joined: 3 weeks ago

Active Member
Posts: 4

@asti hey Asti, could I get more support on this please. How would I use `pre_get_comments` to perform a custom filter on the comments before they're loaded using WpDiscuz? At the moment it's just loaded every comment created on every wall page

Reply
Asti
 Asti
Support
(@asti)
Joined: 6 years ago

Illustrious Member
Posts: 6223

@solodevelops,

Some examples are provided here: https://www.itsupportguides.com/knowledge-base/wordpress/using-wordpress-pre_get_comments-php-action/

Reply
(@solodevelops)
Joined: 3 weeks ago

Active Member
Posts: 4

@asti Hey Asti!

Β 

It's me again. I am going through my file manager and was wondering if you could tell me which file from the WpDiscuz plugin is responsible for displaying the comments via using the WP native comment retrieval mechanism?

Reply
Share: