Support » Fixing WordPress » 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)
  • Can’t you use the default wordpress comment handling?

    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.

    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…

    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.

    Not sure about this. What I would look into:

    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.