Skip Navigation

[Resolved] View for Comments

This thread is resolved. Here is a description of the problem and solution.

Problem:

I noticed comments are not an option in Views. Is there a way to do this in Toolset?

Solution:

Toolset Views/Blocks plugins does not support WordPress Comments, see details here:

https://toolset.com/forums/topic/view-for-comments/#post-2189941

Relevant Documentation:

This support ticket is created 2 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 5 replies, has 3 voices.

Last updated by aaronM-9 2 years, 6 months ago.

Assisted by: Luo Yang.

Author
Posts
#2189177

I would like to make a view that allows me to filter out and display comments, but I noticed comments are not an option in Views. Is there a way to do this in Toolset? Specifically, I need it to pull out the comment that has the most likes on a given post (which is stored in a meta value). Thanks for any help you can offer.

- Aaron

#2189503

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

It is true that Views don't support the comment post type, not sure why but they never have.

You could try creating a View for some other post type, including a query filter for the custom field in question, and then use the wpv_filter_query API filter to modify the argument for the post_type to change it to comments.

I haven't tried it but I expect that it would probably work.

https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query

#2189797

Thanks. Before I dig deeper, aren't comments stored separately (in the "comments" table instead of "posts"), so would it actually work to treat this as a post type for filtering purposes?

#2189941

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Doh. Of course you are right.

I was taking my cue from the question about using a View to display them and for a moment had it in mind that they were stored as posts with a type of comment, but they are indeed stored in their own table, sorry.

And that means a View cannot be used to display them, even legacy Views only supports posts, taxonomies, and users, there is no support for comments.

The official documentation for get_comments() is pretty sparse (https://developer.wordpress.org/reference/classes/wp_comment_query/get_comments/), you might try this guide which includes using meta query to filter comments by some custom field: hidden link

#2190385

Hello,

Toolset Views/Blocks plugins does not support WordPress Comments,
Please let me know if you still need assistance for it, thanks

#2190825

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.