• To give you a real world example of what I mean, I’m wanting to create a page that uses two comment forms, and displays the comments from those two forms in two separate lists. First of all I thought about adding a comment type, but that doesn’t seem to be extendible. So then I thought about comment meta.

    We can add comment meta with add_comment_meta, and then get that comment meta for a given comment with get_comment_meta. Given that posts can be retrieved based on custom field meta with query_posts, why can’t comments be retrieved based on their meta keys and values?

    I realise this is a limited case scenario, but there must be a way of doing it using WordPress’ built in functions and not running my own sql select query.

    I’ve spent a fair while searching, and not found anything. Anyone have any pointers? It seems like a logical step would be to add args to wp_list_comments allowing for meta_key= and meta_value=. Thoughts?

    I may have missed something blindingly obvious, of course!

    Thanks in advance

Viewing 2 replies - 1 through 2 (of 2 total)
  • The documentation for wp_list_comments mentions a ‘callback’ parameter:

    The name of a custom function to use to display each comment. Defaults to null. Using this will make your custom function get called to display each comment, bypassing all internal WordPress functionality in this respect. Use to customize comments display for extreme changes to the HTML layout. Use with caution.

    You might be able to use a callback to filter the comments on a meta value (I haven’t looked at it closely enough to know for sure).

    https://codex.www.ads-software.com/Function_Reference/wp_list_comments

    Thread Starter Alex Cragg

    (@epicalex)

    Thanks for the reply. I use the callback currently to use a custom html structure, and to separate trackbacks and comments (which I don’t think you need to do now to separate them?), but I don’t think it would help from what I can see.

    There is an args parameter available in the custom function for the callback, but I think that just refers to the same args as in the wp_list_comments function…?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘List comments by comment meta’ is closed to new replies.