Title: Filter Comments via Query String
Last modified: August 20, 2016

---

# Filter Comments via Query String

 *  [meno19](https://wordpress.org/support/users/meno19/)
 * (@meno19)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/filter-comments-via-query-string/)
 * I have a page enabled with comments. Their is a query string that is associated
   with this page. How would I be able to filter what comments to show based on 
   a query string?

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [Peter_L](https://wordpress.org/support/users/peter_l/)
 * (@peter_l)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/filter-comments-via-query-string/#post-2723961)
 * Can’t you use the default wordpress comment handling?
    [http://codex.wordpress.org/Function_Reference/wp_list_comments](http://codex.wordpress.org/Function_Reference/wp_list_comments)
 *  Thread Starter [meno19](https://wordpress.org/support/users/meno19/)
 * (@meno19)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/filter-comments-via-query-string/#post-2723977)
 * Yes I am using the default comment handling but this is my situation.
 * I have a page that the content changes based on the query string that is passed
   to it. So think of a Product Detail Page. It is the same individual WordPress
   page but different content based on the query string.
 * So I would like to use the default comment handling for writing and storing posts,
   but when the page loads I only want to show the comments that are for that product.
 * Idea would be to select all of the comments for that page and then only show 
   the ones that are associated with the query string that I pass to it.
 *  [Peter_L](https://wordpress.org/support/users/peter_l/)
 * (@peter_l)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/filter-comments-via-query-string/#post-2723985)
 * Why don’t you use posts? (if necessary custom post types). Then you can get one
   post/product and use the default comments.
 * Oh, and as for your problem, sorry no idea. I’d say, if it’s a query string you
   could get it with php $_GET.
 * But, it just sounds weird to me. It’s like building a custom CMS system on top
   of WP…
 *  Thread Starter [meno19](https://wordpress.org/support/users/meno19/)
 * (@meno19)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/filter-comments-via-query-string/#post-2723989)
 * Sorry I may not be explaining quite right.
 * What I am doing is I have a Plugin that creates a search engine functionality
   for a set of products that are loaded into its own table. I will have thousands
   of products in the table. The search engine page searches via a custom search
   and generates the list of products. If a user clicks on a result it takes you
   to the product detail page which is a standard wordpress page. The overall shell
   of the page is a template but the data loaded in it is dependent upon the query
   string that is sent over in the URL.
 * So I have the pages loading fine, I get the query string and query the data for
   that product.
 * What I am trying to do is enable comments on that page. That is easy enough as
   comments can just be enabled but the comments will be recorded at the page level
   with no regard to the query string.
 * I overcome this by also posting the query idea to the comments meta data table.
   This allows me to associate the comment with the query id. All I have to do now
   is filter the comments so that only the comments for that item display on the
   page.
 * Trick is how can I filter the comments as they get queried to the page.
 * Let me know if that made more sense.
 *  [Peter_L](https://wordpress.org/support/users/peter_l/)
 * (@peter_l)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/filter-comments-via-query-string/#post-2723996)
 * Not sure about this. What I would look into:
 * [http://codex.wordpress.org/Function_Reference/get_comments](http://codex.wordpress.org/Function_Reference/get_comments)
 * This gets you an array of all the comments. This is a php array so you can process
   it with php using the variables from your query string.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Filter Comments via Query String’ is closed to new replies.

## Tags

 * [Comments](https://wordpress.org/support/topic-tag/comments/)
 * [filter](https://wordpress.org/support/topic-tag/filter/)
 * [Query String](https://wordpress.org/support/topic-tag/query-string/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 2 participants
 * Last reply from: [Peter_L](https://wordpress.org/support/users/peter_l/)
 * Last activity: [14 years, 1 month ago](https://wordpress.org/support/topic/filter-comments-via-query-string/#post-2723996)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
