WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 12 days ago

Last modified 12 days ago

#16431 closed enhancement (duplicate)

Adding include to wp_list_comments()

Reported by: danielpataki Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.7
Component: Comments Keywords: reporter-feedback
Focuses: Cc:

Description

I have been building a simple forum on Wordpress using posts as questions, top-level comments as answers, replies as comments on answers.

Choosing a best answer is available, which adds the ID of the chosen answer (comment) ti the postmeta of the question.

I would like to arrange my answers so that the first one is the chosen best answer, and below you can view the normal flow of answers.

It would be nice if this could be done using wp_list_comments(). I would call it once and use "include" to show just the one comment, and then I would call it again without the include to show the usual flow of comments.

I believe this might be generally helpful in other cases as well though.

Change History (9)

comment:1 @ptahdunbar4 years ago

  • Cc trac@… added

comment:2 @c3mdigital23 months ago

  • Component changed from General to Comments
  • Resolution set to wontfix
  • Status changed from new to closed
  • Version set to 2.7

Not sure if I understand what you mean by include. I agree that wp_list_comments() could use some love but we need a clear direction and additional use cases.

Related: #19581

comment:3 follow-up: @danielpataki23 months ago

Hi c3mdigital,

My description was not great, sorry :) I meant that basically adding the same functionality as allowed by WP_Query (where appropriate) would be great. Once example of this would be to have a parameter like 'postin' which would allow you to grab specific comments by ID. A meta_query could also be possible.

Daniel

comment:4 in reply to: ↑ 3 @c3mdigital23 months ago

  • Resolution wontfix deleted
  • Status changed from closed to reopened

Replying to danielpataki:

Hi c3mdigital,

My description was not great, sorry :) I meant that basically adding the same functionality as allowed by WP_Query (where appropriate) would be great. Once example of this would be to have a parameter like 'postin' which would allow you to grab specific comments by ID. A meta_query could also be possible.

Daniel

Thanks for the clarification. #19581 is requesting a filter for the wp_list_comments args which would allow you to pass in additional WP_Query parameters. I'm going to change the resolution on this to duplicate since 19581 has a patch. +1 on the need to use WP_Query parameters.

comment:5 @c3mdigital23 months ago

  • Resolution set to duplicate
  • Status changed from reopened to closed

Duplicate of #19581.

comment:6 follow-up: @danielpataki23 months ago

Great, thanks for giving this some attention :) Should a new ticket be opened for the WP_Query parameters, or is it covered somewhere already?

Daniel

comment:7 in reply to: ↑ 6 @c3mdigital23 months ago

  • Keywords reporter-feedback added
  • Resolution duplicate deleted
  • Status changed from closed to reopened

Replying to danielpataki:

Great, thanks for giving this some attention :) Should a new ticket be opened for the WP_Query parameters, or is it covered somewhere already?

Daniel

Actually that this shouldn't be marked as a duplicate. The filter on #19581 is not for any query arguments. I was thinking of get_comments() which does allow for query arguments for WP_Comment_Query which are a little different than WP_Query.

I think in your case a new WP_Comment_Query sorting by meta_data would work. Pass the ordered results to wp_list_comments.

WP_Comment_Query query_vars:

			'author_email' => '',
			'ID' => '',
			'karma' => '',
			'number' => '',
			'offset' => '',
			'orderby' => '',
			'order' => 'DESC',
			'parent' => '',
			'post_ID' => '',
			'post_id' => 0,
			'post_author' => '',
			'post_name' => '',
			'post_parent' => '',
			'post_status' => '',
			'post_type' => '',
			'status' => '',
			'type' => '',
			'user_id' => '',
			'search' => '',
			'count' => false,
			'meta_key' => '',
			'meta_value' => '',
			'meta_query' => '',

Do we need additional WP_Comment_Query query_vars?

comment:8 @danielpataki23 months ago

I think that while there, we might as well consider commentin and commentnot_in parameters. comment_parentin and comment_parentnot_in might also be an option although probably not that useful. Do you think adding a paged parameter might be useful?

While I would guess this would mostly be relegated to plugins, a post_tax_query could be useful for displaying comments for posts in specific taxonommies.

Daniel

comment:9 @rachelbaker12 days ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from reopened to closed

Duplicate of #24826.

WP_Comment_Query now supports additional query_vars, including: comment__in, comment__not_in, offset, etc. Closing this ticket because I believe [31793] handles the use-cases provided

Note: See TracTickets for help on using tickets.