WordPress.org

Ready to get started?Download WordPress

Forums

Show only page's comments where custom field equals querystring (3 posts)

  1. jonathon.oates
    Member
    Posted 2 years ago #

    I would like to only display the comments for a page but only those that match a querystring param.

    I think I need to use custom fields for this and could probably work out how to add custom fields to each comment but have no idea how to retrieve them.

    For example:

    If I visited

    http://doma.in/blog/a-page/?custom-field=135

    I'd like to see only the comments for that page, where the comments custom field equals 135.

    Is this possible, and could you point me in the direction of some documentation on this or provide an example for me to play with.

    Very much appreciated all! Thank you!

  2. keesiemeijer
    moderator
    Posted 2 years ago #

    Maybe get_comments(): http://codex.wordpress.org/Function_Reference/get_comments

    Or do you want to show comments only on one Page?

  3. jonathon.oates
    Member
    Posted 2 years ago #

    @keesiemeijer I'd like to show, for example, say the page's ID was "15", just the comments for page "15". But, I only want to show the comments for page "15" that also have a custom field with a value of "1" (for example).

    So if I were to navigate to:
    http://doma.in/blog/?page_id=15&custom-comments-field=1

    Page 15 may have 30 comments, but I only want to show the comments that have a custom field that equals '1' (the `&custom-comments-field' param).

    I hope this paints a clearer picture! Thank you!

Topic Closed

This topic has been closed to new replies.

About this Topic